{"action":"created","issue":{"url":"https://api.github.com/repos/linq2db/linq2db/issues/930","repository_url":"https://api.github.com/repos/linq2db/linq2db","labels_url":"https://api.github.com/repos/linq2db/linq2db/issues/930/labels{/name}","comments_url":"https://api.github.com/repos/linq2db/linq2db/issues/930/comments","events_url":"https://api.github.com/repos/linq2db/linq2db/issues/930/events","html_url":"https://github.com/linq2db/linq2db/issues/930","id":276483595,"number":930,"title":"CreateTable: SQLite needs Integer—not BigInt—for AUTOINCREMENT fields","user":{"login":"quole","id":800133,"avatar_url":"https://avatars1.githubusercontent.com/u/800133?v=4","gravatar_id":"","url":"https://api.github.com/users/quole","html_url":"https://github.com/quole","followers_url":"https://api.github.com/users/quole/followers","following_url":"https://api.github.com/users/quole/following{/other_user}","gists_url":"https://api.github.com/users/quole/gists{/gist_id}","starred_url":"https://api.github.com/users/quole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quole/subscriptions","organizations_url":"https://api.github.com/users/quole/orgs","repos_url":"https://api.github.com/users/quole/repos","events_url":"https://api.github.com/users/quole/events{/privacy}","received_events_url":"https://api.github.com/users/quole/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-23T23:09:29Z","updated_at":"2017-11-23T23:10:30Z","closed_at":null,"author_association":"NONE","body":"SQL generated by `CreateTable()` looks something like this:\r\n\r\n> CREATE TABLE [FailTable]( [id] **BigInt** PRIMARY KEY AUTOINCREMENT )\r\n\r\nwhich produces this error:\r\n\r\n> AUTOINCREMENT is only allowed on an **INTEGER** PRIMARY KEY\r\n\r\nSQLite does not actually have **BigInt** type, instead automatically replacing it with **Integer** via its \"[type affinity](https://sqlite.org/datatype3.html)\" system. However, for some reason, possibly a bug in SQLite, in this particular case it fails to treat the two types synonymously, and the user (or linq2db in this case) needs to replace **BigInt** with **Integer** manually to avoid the above error. e.g.\r\n\r\n> CREATE TABLE [OkTable]( [id] **Integer** PRIMARY KEY AUTOINCREMENT )\r\n\r\nlinq2db should replace **BigInt** with **Integer** in its SQL generation when creating tables. **BigInt** is otherwise treated the same as **Integer** in SQLite so this shouldn't lead to any problems (hopefully).\r\n\r\nI am using version 1.10.0 via NuGet."},"comment":{"url":"https://api.github.com/repos/linq2db/linq2db/issues/comments/346707820","html_url":"https://github.com/linq2db/linq2db/issues/930#issuecomment-346707820","issue_url":"https://api.github.com/repos/linq2db/linq2db/issues/930","id":346707820,"user":{"login":"quole","id":800133,"avatar_url":"https://avatars1.githubusercontent.com/u/800133?v=4","gravatar_id":"","url":"https://api.github.com/users/quole","html_url":"https://github.com/quole","followers_url":"https://api.github.com/users/quole/followers","following_url":"https://api.github.com/users/quole/following{/other_user}","gists_url":"https://api.github.com/users/quole/gists{/gist_id}","starred_url":"https://api.github.com/users/quole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quole/subscriptions","organizations_url":"https://api.github.com/users/quole/orgs","repos_url":"https://api.github.com/users/quole/repos","events_url":"https://api.github.com/users/quole/events{/privacy}","received_events_url":"https://api.github.com/users/quole/received_events","type":"User","site_admin":false},"created_at":"2017-11-23T23:10:30Z","updated_at":"2017-11-23T23:10:30Z","author_association":"NONE","body":"Background in case I missed too much context: I use `LoadSQLiteMetadata` and `GenerateModel()` through a `SQLite.tt` template to load in an SQLite database schema. In case the user deletes the database file, my user application attempts to re-create it from scratch. It does this by re-creating each table with `db.CreateTable<>()`. This fails because the SQL generated for SQLite contains **BigInt** instead of **Integer**, leading to the \"AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY\" error."}}
{"actor":{"display_login":"quole"}}