Skip to content

Escaping natural language w/ mysql? #3091

@JakeTrock

Description

@JakeTrock

Version

1.24.0

What happened?

I'm trying to do a little complicated SQL and it seems that I cannot properly escape the natural language to put in a question mark. I always only get 4 params when I should be getting 5. Does anyone know how I could escape the first so I can also have a natural language search param?

Relevant log output

No response

Database schema

CREATE TABLE Profile (
    id SERIAL PRIMARY KEY AUTO_INCREMENT UNIQUE,
    profileOwner VARCHAR(36) NOT NULL,
    name VARCHAR(512) NOT NULL,
    subHead VARCHAR(512) NOT NULL,
    body TEXT,
    locationLat FLOAT,
    locationLon FLOAT,
    createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updatedAt TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (profileOwner) REFERENCES User(id) ON DELETE CASCADE,
    FULLTEXT (name, body, subHead)
);

SQL queries

SELECT * FROM
    Profile
WHERE
    MATCH (subHead, body, name) 
    AGAINST (? IN NATURAL LANGUAGE MODE)
    AND locationLat BETWEEN ? AND ?
    AND locationLon BETWEEN ? AND ?;

Configuration

No response

Playground URL

https://play.sqlc.dev/p/69a6c4d31598994f1c63df14d1af302ab36de123d066552e2463b79653580d50

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions