Skip to content

Commit

Permalink
Merge d833bea into cacc0f6
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdd committed Aug 7, 2017
2 parents cacc0f6 + d833bea commit 53408f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mongo_connector/doc_managers/mapping_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
},
"dest": {
"type": "string"
},
"nullable": {
"type": "boolean"
}
},
"required": ["type"]
Expand All @@ -131,7 +134,10 @@
"properties": {
"type": {"enum": ["_ARRAY"]},
"dest": {"type": "string"},
"fk": {"type": "string"}
"fk": {"type": "string"},
"nullable": {
"type": "boolean"
}
},
"required": ["type", "dest", "fk"]
},
Expand All @@ -140,7 +146,10 @@
"type": {"enum": ["_ARRAY_OF_SCALARS"]},
"dest": {"type": "string"},
"fk": {"type": "string"},
"valueField": {"type": "string"}
"valueField": {"type": "string"},
"nullable": {
"type": "boolean"
}
},
"required": ["type", "dest", "fk", "valueField"]
}
Expand Down
4 changes: 4 additions & 0 deletions mongo_connector/doc_managers/postgresql_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@ def _init_schema(self):
if 'dest' in column_mapping:
name = column_mapping['dest']
column_type = column_mapping['type']
nullable = column_mapping.get('nullable', True)

constraints = ''
if name == pk_name:
constraints = "CONSTRAINT {0}_PK PRIMARY KEY".format(collection.upper())
pk_found = True

if not nullable:
constraints = '{} NOT NULL'.format(constraints)

if column_type != ARRAY_TYPE and column_type != ARRAY_OF_SCALARS_TYPE:
columns.append(name + ' ' + column_type + ' ' + constraints)

Expand Down

0 comments on commit 53408f9

Please sign in to comment.