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

Table Creation DSL #93

Merged
merged 79 commits into from
Aug 6, 2016
Merged

Table Creation DSL #93

merged 79 commits into from
Aug 6, 2016

Conversation

groue
Copy link
Owner

@groue groue commented Aug 6, 2016

This PR closes #83.

It contains:

  • A DSL for creating and altering tables and indexes
  • Support for the LENGTH SQLite built-in function (it helps documenting CHECK constraints)
  • New SQLCollation enum replaces collation names everywhere in the API
  • Extensive testing and documentation
  • Unrelated: renaming of PrimaryKey into PrimaryKeyInfo, for consistency with ColumnInfo and IndexInfo.

Many thanks, @cfilipov, for your intense and great contributions. This would have simply not existed without you.

@groue groue merged commit 1d77523 into master Aug 6, 2016
@groue
Copy link
Owner Author

groue commented Aug 7, 2016

@cfilipov Support for table creation DSL has landed in v0.78.0, now merged into the Swift3 branch (documentation).

Implementation was rather straightforward, since we two have been discussing the subject in depth: https://github.com/groue/GRDB.swift/blob/Swift3/GRDB/QueryInterface/SQLTableBuilder.swift

You'll see that:

  • SQLColumn has been renamed Column, as you have suggested 😄
  • The ASC/DESC in INTEGER PRIMARY KEY ASC is not supported: I simply did not understand the purpose/usefulness of these modifiers.
  • Index on collated columns are not supported: CREATE INDEX foo ON bar(baz COLLATE NOCASE)
  • Default values for columns are defined with a DatabaseValueConvertible value, not an expression. This is because SQLite, in practice, only accepts literals and expressions that evaluate to a constant.

There is always room for improvement: I hope that you'll provide feedback after you have played with this new API a little.

@groue groue deleted the SQLTableBuilder branch August 7, 2016 10:14
@cfilipov
Copy link

cfilipov commented Aug 9, 2016

@groue This looks wonderful! I've pulled the latest Swift3 branch and started playing with the lib. Switching to GRDB has been great, I'm really happy with the quality of this lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL Builder for CREATE TABLE
2 participants