Skip to content

Why isn't ColumnInfo.columnType public? #1560

Closed Answered by groue
mallman asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @mallman,

Why isn't ColumnInfo.columnType public?

This is because ColumnType is a type dedicated to schema definition, not to schema introspection.

ColumnType provides ready-made constants for frequently used column types: .integer, .text, .boolean, etc. But it is not an enum. It is a struct. SQLite accepts about everything as a column type. For example, consider those three columns:

try db.create(table: "myTable") { t in
  t.column("a", .boolean)                        // 1
  t.column("b", ColumnType(rawValue: "BOOL"))    // 2
  t.column("c", ColumnType(rawValue: "PIKACHU")) // 3
}

All of them are valid ways to declare columns that store booleans. 2 is original but quite OK; 3 is…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@groue
Comment options

Answer selected by mallman
Comment options

mallman
Jun 20, 2024
Collaborator Author

You must be logged in to vote
1 reply
@groue
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants