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

NULL and number literals in schemas converted to ? #10

Open
phrohdoh opened this issue Oct 23, 2016 · 3 comments
Open

NULL and number literals in schemas converted to ? #10

phrohdoh opened this issue Oct 23, 2016 · 3 comments
Labels

Comments

@phrohdoh
Copy link

phrohdoh commented Oct 23, 2016

This does not seem correct to me.
Neither 50 or NULL are placeholder values.

CREATE TABLE puf2017 (
  Id int IDENTITY,
  DrugTier nvarchar(max) NOT NULL,
  PriorAuthorization bit NOT NULL,
  QuantityLimit bit NOT NULL,
  StepTherapy bit NOT NULL,
  StandardComponentId nvarchar(50) NOT NULL,
  BusinessYear int NOT NULL
)
GO
CREATE TABLE puf2017 (
  Id int IDENTITY,
  DrugTier nvarchar(max) NOT ?,
  PriorAuthorization bit NOT ?,
  QuantityLimit bit NOT ?,
  StepTherapy bit NOT ?,
  StandardComponentId nvarchar(?) NOT ?,
  BusinessYear int NOT ?
)
GO

These tests pass so the sanitation is definitely to blame, not lexing:

    #[test]
    fn test_not_null() {
        let sql = "NOT NULL";
        let written = helpers::lex_and_write(sql.to_string());

        assert_eq!(written, sql);
    }

    #[test]
    fn test_std_cmpnt_id() {
        let sql = "StandardComponentId nvarchar(50) NOT NULL";
        let written = helpers::lex_and_write(sql.to_string());

        assert_eq!(written, sql);
    }
@phrohdoh phrohdoh changed the title NULL 'sanitized' to ? NULL and number literals converted to ? Oct 23, 2016
@phrohdoh
Copy link
Author

The issue is that schema was, apparently, never considered for sanitation input so there are no checks for table creation.

This means that NOT is always seen as a comparison and not a condition.

@phrohdoh
Copy link
Author

Upon further investigation this is more clear as Create and Table are not keywords.
I may give this a shot in my freetime over at my fork, if anyone is interested.

@thijsc
Copy link
Member

thijsc commented Oct 27, 2016

Indeed. We didn't need schemas for our use case of sanitizing queries that commonly occur in ActiveRecord. I would like to support this though. I'll add support for this, but have to see when I can find some time :-).

If you'd like to take a stab, that'd be great too.

@thijsc thijsc self-assigned this Nov 29, 2017
@tombruijn tombruijn added the bug label May 15, 2018
@unflxw unflxw changed the title NULL and number literals converted to ? NULL and number literals in schemas converted to ? Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants