Skip to content

Support prepared statement placeholder arg ? and $ - #420

Merged
alamb merged 1 commit into
apache:mainfrom
gamife:feature/placeholder
Feb 17, 2022
Merged

alamb merged 1 commit into
apache:mainfrom
gamife:feature/placeholder

Conversation

@gamife

@gamife gamife commented Feb 11, 2022 •

Copy link
Copy Markdown
Contributor

#145 support ? or $foo prepared statement arg placeholder.

SELECT * FROM student WHERE id = ?;
SELECT * FROM student WHERE id = $Id1;

@coveralls

coveralls commented Feb 11, 2022 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 1827316036

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 24 of 27 (88.89%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.006%) to 90.588%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser.rs 3 4 75.0%
src/tokenizer.rs 6 8 75.0%
Totals Coverage Status
Change from base Build 1818592432: -0.006%
Covered Lines: 7074
Relevant Lines: 7809

💛 - Coveralls

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks (again) for the contribution @gamife

Comment thread src/ast/value.rs
},
/// `NULL` value
Null,
/// `?` or `$` Prepared statement arg placeholder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not familiar with the $ syntax for prepared argument placeholders. What database system do they come from?

I have only ever seen ? used for prepared statement placeholders

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here is an example from pgsql's document.

PREPARE fooplan (int, text, bool, numeric) AS
    INSERT INTO foo VALUES($1, $2, $3, $4);
EXECUTE fooplan(1, 'Hunter Valley', 't', 200.00);

However, only numbers follow the $.
Then I found that there was a need for $foo in the issue. #145 (comment)

So the final product is this:

SELECT * FROM student WHERE id = $Id1;

Maybe there can't be a separate $placeholder here.

Thank you even more for your continued contribution. I'm just a spoon of water in the ocean :-)

@alamb alamb changed the title feat: add arg placeholder Add prepared statement placeholder arg ? Feb 16, 2022
@alamb alamb changed the title Add prepared statement placeholder arg ? Support prepared statement placeholder arg ? Feb 16, 2022
@alamb alamb changed the title Support prepared statement placeholder arg ? Support prepared statement placeholder arg ? and $ Feb 17, 2022

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 thanks @gamife

@alamb
alamb merged commit 899f91b into apache:main Feb 17, 2022
ovr pushed a commit to cube-js/sqlparser-rs that referenced this pull request Mar 28, 2022
Co-authored-by: gamife <gamife9886@gmail.com>
ovr pushed a commit to cube-js/sqlparser-rs that referenced this pull request Apr 14, 2023
Co-authored-by: gamife <gamife9886@gmail.com>
@git-hulk git-hulk mentioned this pull request Aug 19, 2024
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.

4 participants