File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed
Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -34,17 +34,24 @@ def __init__(self, **kwargs) -> None:
3434DEFAULT = Unquoted ('DEFAULT' )
3535NULL = Unquoted ('null' )
3636
37+
3738class PrimaryKey (Column ):
3839 # Was column_type = 'SERIAL' for Postgres
3940 column_type = 'INTEGER'
4041
42+ def default (self , engine_type : str = 'postgres' ):
43+ if engine_type == 'postgres' :
44+ return DEFAULT
45+ elif engine_type == 'sqlite' :
46+ return NULL
47+ else :
48+ raise Exception ('Unrecognized engine type' )
49+
4150 def __init__ (self , ** kwargs ) -> None :
4251 kwargs .update ({
4352 'primary' : True ,
4453 'key' : True
4554 })
46- # self.default = DEFAULT for Postgres
47- self .default = NULL
4855 super ().__init__ (** kwargs )
4956
5057
Original file line number Diff line number Diff line change @@ -199,7 +199,9 @@ def __init__(self, **kwargs):
199199 # Can't use inspect - can't tell that datetime.datetime.now
200200 # is a callable.
201201 is_callable = hasattr (column .default , '__call__' )
202- value = column .default () if is_callable else column .default
202+ value = column .default (
203+ engine_type = self .Meta .db .engine_type
204+ ) if is_callable else column .default
203205 else :
204206 if not column .null :
205207 raise ValueError (f"{ column ._name } wasn't provided" )
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ def test_rename(self):
1616
1717 rename_query .run_sync ()
1818
19+ # The problem now is select * has changed
20+ # Need to use a raw select query instead ...
1921 select_query = Band .select
2022 response = select_query .run_sync ()
2123
You can’t perform that action at this time.
0 commit comments