From e77639033ab918ce3c29a9f646662112575d1709 Mon Sep 17 00:00:00 2001 From: Andreas Sommer Date: Sat, 3 Jun 2017 00:41:44 +0200 Subject: [PATCH] Support implicitly treating id column as auto-incrementing (e.g. for SQLite) --- scripts/ddl2cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index 603080bf..d0406c15 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -112,6 +112,7 @@ optionalArgs = { # '-no-time-stamp-warning' # timeStampWarning = False '-fail-on-parse': "abort instead of silent genereation of unusable headers", # failOnParse = 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" } @@ -127,6 +128,7 @@ timestampWarning = True failOnParse = False warnOnParse = False parseError = "Parsing error, possible reason: can't parse default value for a field" +autoId = False if len(sys.argv) >= 4: @@ -301,6 +303,7 @@ for create in tableCreations: print ('Error: datatype "' + sqlColumnType + '"" is not supported.') DataTypeError = True requireInsert = True + column.hasAutoValue = column.hasAutoValue or (autoId and sqlColumnName == 'id') if column.hasAutoValue: traitslist.append(NAMESPACE + '::tag::must_not_insert') traitslist.append(NAMESPACE + '::tag::must_not_update')