Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLITE_DQS Compile Option #1269

Open
figaro-smartotum opened this issue Apr 9, 2024 · 8 comments · Fixed by #1169
Open

SQLITE_DQS Compile Option #1269

figaro-smartotum opened this issue Apr 9, 2024 · 8 comments · Fixed by #1169
Labels

Comments

@figaro-smartotum
Copy link

Just a note for other people that could incurr in the same issue performing a similar task.
I am trying to perform a pretty challenging task. I want to use this ORM on an STM32 microcontroller having just a few of kBytes of RAM and less than 2MB of free program memory, using LittleFS as filesystem.

I implemented a dedicated VFS for SQLite and registered sqlite3_vfs_register.
Since many other compile-time defines are involved in order to reduce the code size, I was also using SQLITE_DQS=0 as recommended in the SQLite doc.

The recommended setting is 0, meaning that double-quoted strings are disallowed in all contexts. However, the default setting is 3 for maximum compatibility with legacy applications.

But it turns that sqlite_orm requires the SQLITE_DQS=3 compile definition, since it heavily relies on double-quoted strings.

It is wonderful to be able to use such abstraction level on a really minimal hardware like an STM32 microcontroller.
Many thanks to all

@fnc12
Copy link
Owner

fnc12 commented Apr 10, 2024

hi. It is a very interesting case. As I understood you need to make sqlite_orm serializer to replace double quotes with single quotes to make your code working on your controller. Is it right?

@fnc12 fnc12 added the question label Apr 10, 2024
@figaro-smartotum
Copy link
Author

figaro-smartotum commented Apr 10, 2024 via email

@trueqbit
Copy link
Collaborator

@figaro-smartotum Nice to see a Rossini fan 😏

It's not clear to me how sqlite_orm "heavily relies on double-quoted strings".
sqlite_orm sets all identifiers correctly in double quotation marks and sets string literals correctly in single quotation marks, unless there is an error.

Can you show how and where you encounter the problem?

@figaro-smartotum
Copy link
Author

The query for checking if the table exists, when performing the sync_schema is failing if DQS == 0.

@trueqbit
Copy link
Collaborator

sqlite_orm properly quotes and escapes the table name.

@figaro-smartotum
Copy link
Author

figaro-smartotum commented May 17, 2024

(28) double-quoted string literal: "table"
warning reported when executing

"SELECT COUNT(*) FROM sqlite_master WHERE type = \"table\" AND name = '<<tablename>>'"

The function where the warning is triggered is
bool table_exists(sqlite3* db, const std::string& tableName) const

In this context ŧable is a string literal, so sqlite is expecting a single quote.

@trueqbit
Copy link
Collaborator

trueqbit commented May 17, 2024

Did you actually look at the link I mentioned above? You didn't mention that you are using sqlite_orm v1.8.2 on master. This issue was fixed more than a year ago in the dev branch, which was part of PR #1169.

@trueqbit trueqbit linked a pull request May 17, 2024 that will close this issue
@fnc12
Copy link
Owner

fnc12 commented Oct 13, 2024

@figaro-smartotum does the issue still exist in your work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants