0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Support implicitly treating id column as auto-incrementing (e.g. for SQLite)

This commit is contained in:
Andreas Sommer 2017-06-03 00:41:44 +02:00
parent d0c6cc103a
commit e77639033a

View File

@ -112,6 +112,7 @@ optionalArgs = {
# '-no-time-stamp-warning' # timeStampWarning = False # '-no-time-stamp-warning' # timeStampWarning = False
'-fail-on-parse': "abort instead of silent genereation of unusable headers", # failOnParse = True '-fail-on-parse': "abort instead of silent genereation of unusable headers", # failOnParse = True
'-warn-on-parse': "warn about unusable headers, but continue", # warnOnParse = True '-warn-on-parse': "warn about unusable headers, but continue", # warnOnParse = True
'-auto-id': "Assume column 'id' to have an automatic value as if AUTO_INCREMENT was specified (e.g. implicit for SQLite ROWID)", # autoId = True
'-help': "show this help" '-help': "show this help"
} }
@ -127,6 +128,7 @@ timestampWarning = True
failOnParse = False failOnParse = False
warnOnParse = False warnOnParse = False
parseError = "Parsing error, possible reason: can't parse default value for a field" parseError = "Parsing error, possible reason: can't parse default value for a field"
autoId = False
if len(sys.argv) >= 4: if len(sys.argv) >= 4:
@ -301,6 +303,7 @@ for create in tableCreations:
print ('Error: datatype "' + sqlColumnType + '"" is not supported.') print ('Error: datatype "' + sqlColumnType + '"" is not supported.')
DataTypeError = True DataTypeError = True
requireInsert = True requireInsert = True
column.hasAutoValue = column.hasAutoValue or (autoId and sqlColumnName == 'id')
if column.hasAutoValue: if column.hasAutoValue:
traitslist.append(NAMESPACE + '::tag::must_not_insert') traitslist.append(NAMESPACE + '::tag::must_not_insert')
traitslist.append(NAMESPACE + '::tag::must_not_update') traitslist.append(NAMESPACE + '::tag::must_not_update')