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

Disallow more non-deterministic queries in writes #2018

Merged
merged 2 commits into from
Dec 12, 2024
Merged

Conversation

coleaeason
Copy link
Contributor

Details

Disallows more non-deterministic functions in writes, and adds comments about how this feature works in general.

I didn't add tests for all of the functions, but happy to if useful.

Also fixes a typo, sqlite3_version is not a real function, its sqlite_version.

sqlite> SELECT sqlite_version();
authorizer: SELECT NULL NULL NULL NULL
authorizer: FUNCTION NULL "sqlite_version" NULL NULL
3.47.0
sqlite> SELECT sqlite3_version();
authorizer: SELECT NULL NULL NULL NULL
Parse error: no such function: sqlite3_version
  SELECT sqlite3_version();
         ^--- error here
sqlite>

Fixed Issues

Related issues in https://github.com/Expensify/Expensify/issues/451388

Tests

Added automated tests


Internal Testing Reminder: when changing bedrock, please compile auth against your new changes

@coleaeason coleaeason self-assigned this Dec 12, 2024
Copy link
Contributor

@tylerkaraszewski tylerkaraszewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to update WriteTest

Copy link
Contributor

@tylerkaraszewski tylerkaraszewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved but I have a suggestion if you want to change it.

@@ -38,7 +39,8 @@ struct WriteTest : tpunit::TestFixture {
for (int i = 0; i < 50; i++) {
SData query("Query");
query["writeConsistency"] = "ASYNC";
query["query"] = "INSERT INTO foo VALUES ( RANDOM() );";
uint64_t rand = SRandom::rand64();
query["query"] = "INSERT INTO foo VALUES (" + to_string(rand) + ");";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQ(SRandom::rand64())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the column is defined as INTEGER so i left it unquoted

Copy link
Contributor

@tylerkaraszewski tylerkaraszewski Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQ does the right thing with integers (makes them strings)

@coleaeason coleaeason merged commit cf54b48 into main Dec 12, 2024
1 check passed
@coleaeason coleaeason deleted the cole_nd_queries branch December 12, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants