MOD: updated the regex to be more flexible with whitespace
This commit is contained in:
parent
5d4d351248
commit
ebc70cfdb8
|
@ -342,7 +342,7 @@ class TableDefinition:
|
|||
return newField
|
||||
# pinned INTEGER NOT NULL DEFAULT 2147483647
|
||||
# send_to_voicemail INTEGER NOT NULL DEFAULT 0
|
||||
results = re.match(r'(?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\s+(\w+)\s+NOT.NULL\s+DEFAULT\s+(\w+)', sqltext, re.IGNORECASE)
|
||||
results = re.match(r'(?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\s+(\w+)\s+NOT\s+NULL\s+DEFAULT\s+(\w+)', sqltext, re.IGNORECASE)
|
||||
if results:
|
||||
newField['name'] = results.group(1)
|
||||
newField['datatype'] = results.group(2)
|
||||
|
@ -358,7 +358,7 @@ class TableDefinition:
|
|||
newField['default'] = results.group(3)
|
||||
return newField
|
||||
# _id INTEGER PRIMARY KEY AUTOINCREMENT
|
||||
results = re.match(r'(?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\s+(\w+)\s+PRIMARY.KEY\s+AUTOINCREMENT', sqltext, re.IGNORECASE)
|
||||
results = re.match(r'(?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\s+(\w+)\s+PRIMARY\s+KEY\s+AUTOINCREMENT', sqltext, re.IGNORECASE)
|
||||
if results:
|
||||
newField['name'] = results.group(1)
|
||||
newField['datatype'] = results.group(2)
|
||||
|
@ -366,28 +366,28 @@ class TableDefinition:
|
|||
newField['autoincrement'] = True
|
||||
return newField
|
||||
# _id INTEGER PRIMARY KEY
|
||||
results = re.match(r'(?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\s+(\w+)\s+PRIMARY.KEY', sqltext, re.IGNORECASE)
|
||||
results = re.match(r'(?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\s+(\w+)\s+PRIMARY\s+KEY', sqltext, re.IGNORECASE)
|
||||
if results:
|
||||
newField['name'] = results.group(1)
|
||||
newField['datatype'] = results.group(2)
|
||||
newField['primarykey'] = True
|
||||
return newField
|
||||
# FileID INTEGER NOT NULL
|
||||
results = re.match(r'(?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\s+(\w+)\s+NOT.NULL', sqltext, re.IGNORECASE)
|
||||
results = re.match(r'(?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\s+(\w+)\s+NOT\s+NULL', sqltext, re.IGNORECASE)
|
||||
if results:
|
||||
newField['name'] = results.group(1)
|
||||
newField['datatype'] = results.group(2)
|
||||
newField['notnull'] = True
|
||||
return newField
|
||||
# PRIMARY KEY (field_name,
|
||||
results = re.match(r'PRIMARY.KEY\s+\((?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\,?', sqltext, re.IGNORECASE)
|
||||
results = re.match(r'PRIMARY.KEY\s*\((?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\,?', sqltext, re.IGNORECASE)
|
||||
if results:
|
||||
field = self.fields[results.group(1)]
|
||||
field['primarykey'] = True
|
||||
self.primarykeyFlag = True
|
||||
return False
|
||||
# UNIQUE(field_name,
|
||||
results = re.match(r'UNIQUE\((?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\,?', sqltext, re.IGNORECASE)
|
||||
# UNIQUE (field_name,
|
||||
results = re.match(r'UNIQUE\s*\((?:[`|\"|\'])*(\w+)(?:[`|\"|\'])*\,?', sqltext, re.IGNORECASE)
|
||||
if results:
|
||||
field = self.fields[results.group(1)]
|
||||
field['unique'] = True
|
||||
|
|
Loading…
Reference in New Issue