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

Add MySQL SQL PreparedStatements support #665

Merged
merged 8 commits into from
Aug 10, 2023

Conversation

Zhaars
Copy link
Contributor

@Zhaars Zhaars commented Aug 4, 2023

Checklist

@Zhaars Zhaars requested a review from Lagovas August 4, 2023 20:08
@Zhaars Zhaars requested a review from Lagovas August 8, 2023 09:14
@Zhaars Zhaars marked this pull request as ready for review August 8, 2023 09:14
continue
}

item.Expr.Right = &sqlparser.SubstrExpr{
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we replace value with substr in all cases? we may have next cases:

  1. WHERE a=?
  2. WHERE a='value'

In the 1 case we expect here acrastruct/acrablock and we must use substr
In the 2 case we replace 'value' with acrastruct/acrablock or only hash? If we place only hash then we should not replace with substr

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I see below that filterColumnEqualComparisonExprs returns only values as placeholders. Do we handle queries where driver had put value into the query without binding them in execute command?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, we handle this case from OnQuery processing but will add this case to test as well.

self.assertEqual(len(rows), 1)

# deallocate prepared statement from DB and delete statement from session registry
self.deallocate(prepared_name='select_data_by_field', engine=self.engine2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

reading this test pushed to think about the case when driver:

  1. set variables
  2. prepared query with placeholders
  3. executed
  4. deallocated
  5. prepared same query
  6. executed with previously set values

IMHO we should test this case too to be sure that leaving previously set values handled properly in the next prepared statement
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, makes sense

@Zhaars Zhaars requested a review from Lagovas August 9, 2023 14:07
Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

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

lgtm

@Zhaars Zhaars merged commit c6eb412 into master Aug 10, 2023
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