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

Way to create untyped column? #169

Closed
schveiguy opened this issue Feb 17, 2017 · 4 comments
Closed

Way to create untyped column? #169

schveiguy opened this issue Feb 17, 2017 · 4 comments
Labels

Comments

@schveiguy
Copy link
Contributor

SQLite supports columns without a type:

CREATE TABLE example (column1 INT, column2)

However, with GRDB, the table.column function only allows creating columns with a given type:

            db.create(table: "example") { t in
                t.column("column1", .integer)
                t.column("column2") // error
            }

is there a way to do this?

@groue
Copy link
Owner

groue commented Feb 17, 2017

Hello @schveiguy, glad to see you again!

According to SQLite documentation, an untyped column has the exact same behavior as a numeric column:

db.create(table: "example") { t in
    t.column("column1", .integer)
    t.column("column2", .numeric)
}

This will make your code compile, and your database 100% equivalent (but for the syntax of the table declaration).

@schveiguy
Copy link
Contributor Author

Thanks, that looks correct! I will go ahead with this (was just using a create statement, but was sure there was a better way)

@groue
Copy link
Owner

groue commented Jul 1, 2017

Support for untyped columns has landed: 5f2d6f8 in development branch.

@groue
Copy link
Owner

groue commented Jul 13, 2017

Shipped in v1.2

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

2 participants