-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sys period field by default in create table #3
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,13 @@ createdAtField = | |
index: null | ||
references: null | ||
defaultValue: 'CURRENT_TIMESTAMP' | ||
sysPeriodField = | ||
dataType: 'Date Time Range' | ||
fieldName: 'sys period' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does "sys period" mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It means system period. It is a range showing when a record is valid from-to. The temporal extension's convention it to call it "sys period" that's why I named it that way. |
||
required: true | ||
index: null | ||
references: null | ||
defaultValue: 'tstzrange(CURRENT_TIMESTAMP, null)' | ||
exports.TableSpace = -> | ||
tables = {} | ||
|
||
|
@@ -76,7 +83,7 @@ exports.TableSpace = -> | |
currentTable = this | ||
|
||
idField = 'id' | ||
fields = [createdAtField] | ||
fields = [createdAtField, sysPeriodField] | ||
indexes = [] | ||
switch lf[0] | ||
when 'Term' | ||
|
@@ -173,6 +180,7 @@ exports.TableSpace = -> | |
referenceScheme: typeName | ||
fields: [ | ||
createdAtField | ||
sysPeriodField | ||
primitiveField | ||
] | ||
else | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only work for postgres? (the
tstzrange(CURRENT_TIMESTAMP, null)
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there another way to pass the default value and determine automatically the syntax according to the db engine? Also, mysql does not have that datatype.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not currently - it hasn't been necessary before. I guess the best way to do it would be to move the
dataTypeGen
function from abstract-sql-compiler to sbvr-types (I think it makes a lot more sense to be there, as sbvr-types can be a lot smarter in how it handles it in general), and once it's moved then sbvr-types can handle passing the default value through the relevantvalidate
function in order to transform it into the db-specific format