Map BIGINT to INTEGER for SQLite

Message ID 20200321181345.GA4106299@tsubame.mg0.fr
State New
Headers show
Series Map BIGINT to INTEGER for SQLite | expand

Commit Message

Frédéric Mangano-Tarumi March 21, 2020, 6:13 p.m. UTC
---
 aurweb/schema.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Lukas Fleischer March 22, 2020, 8:50 p.m. UTC | #1
On Sat, 21 Mar 2020 at 14:13:45, Frédéric Mangano-Tarumi wrote:
> ---
>  aurweb/schema.py | 11 +++++++++++
>  1 file changed, 11 insertions(+)

Merged, thanks!

Patch

diff --git a/aurweb/schema.py b/aurweb/schema.py
index fde6512f..6792cf1d 100644
--- a/aurweb/schema.py
+++ b/aurweb/schema.py
@@ -17,6 +17,17 @@  def compile_tinyint_sqlite(type_, compiler, **kw):
     return 'INTEGER'
 
 
+@compiles(BIGINT, 'sqlite')
+def compile_bigint_sqlite(type_, compiler, **kw):
+    """
+    For SQLite's AUTOINCREMENT to work on BIGINT columns, we need to map BIGINT
+    to INTEGER. Aside from that, BIGINT is the same as INTEGER for SQLite.
+
+    See https://docs.sqlalchemy.org/en/13/dialects/sqlite.html#allowing-autoincrement-behavior-sqlalchemy-types-other-than-integer-integer
+    """
+    return 'INTEGER'
+
+
 metadata = MetaData()
 
 # Define the Account Types for the AUR.