Skip to content

Conversation

@graham
Copy link

@graham graham commented Apr 26, 2022

While using sqlparser-rs to parse schema from a Django SQLite database I found that deferrable wasn't handled.

Since it exists here: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#_10_8_constraint_name_definition_and_constraint_characteristics I assume it's reasonable for inclusion.

Happy to make changes to the PR as required, relatively new to rust so I'm well aware I may have style/common practice issues.

graham and others added 5 commits April 25, 2022 21:27
@graham graham force-pushed the deferrable-column-option branch from 1e64864 to 89804fd Compare April 26, 2022 04:27
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Hi @graham -- thank you for the contribution! I am sorry I did not see this before. i left some suggestions for your consideration

field: DateTimeField,
expr: Box<Expr>,
},
/// POSITION(<expr> in <expr>)
Copy link
Contributor

Choose a reason for hiding this comment

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

this change appears to be unrelated to DEFERRABLE INITIALLY DEFERRED

I think it was already added in #463

DialectSpecific(Vec<Token>),
CharacterSet(ObjectName),
Comment(String),
DeferrableInitiallyDeferred,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a docstring noting this is from SQLite?

The reference manual https://www.sqlite.org/syntax/foreign-key-clause.html seems to show that it is possible to have NOT INITIALLY DEFERRED as well

What if this was represented with something like

/// SQlite foreign key deferrability
/// https://www.sqlite.org/syntax/foreign-key-clause.html
pub enum DeferType {
  Deferred,
  Immediate
}

pub enum ColumnOption {
...
  /// Sqlite constraint deferrability
  /// https://www.sqlite.org/syntax/foreign-key-clause.html
  Deferrable {
    not: bool,
    defer_type: DeferType,
  }
...

@alamb
Copy link
Contributor

alamb commented Aug 11, 2022

Marking this as a draft to show it is waiting some changes so I can easily filter out which PRs need review. Please mark it as "ready for review" when it is next ready.

@alamb alamb marked this pull request as draft August 11, 2022 10:46
@alamb
Copy link
Contributor

alamb commented Oct 1, 2022

Closing as stale -- please reopen if you still plan to work on it

@alamb alamb closed this Oct 1, 2022
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.

3 participants