sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Escaping natural language w/ mysql?

Open JakeTrock opened this issue 7 months ago • 0 comments

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

JakeTrock avatar Dec 31 '23 05:12 JakeTrock