Skip to content

Commit

Permalink
Bugfix/generate default date value (#51)
Browse files Browse the repository at this point in the history
* style: add recommended extensions

* fix: generate default date value
  • Loading branch information
joao-moonward authored Sep 26, 2023
1 parent 4747324 commit 8d29cb7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["prisma.prisma", "esbenp.prettier-vscode"]
}
15 changes: 8 additions & 7 deletions prisma/mysql.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ model Category {
}

model Company {
id Int @id
name String
totalIncome BigInt @default(100)
lat Decimal
lng Decimal
by Bytes
products Product[]
id Int @id
name String
totalIncome BigInt @default(100)
lat Decimal
lng Decimal
by Bytes
products Product[]
establishedAt DateTime @default("2000-01-01T01:00:00.00Z")
}
6 changes: 5 additions & 1 deletion src/components/field.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export class FieldComponent extends BaseComponent implements Echoable {

let defaultValue = ''
if (this.default) {
defaultValue = `= ${this.default}`
if (!isNaN(Date.parse(this.default))) {
defaultValue = `= new Date('${this.default}')`
} else {
defaultValue = `= ${this.default}`
}
} else {
if (this.useUndefinedDefault === true) {
defaultValue = `= undefined`
Expand Down

0 comments on commit 8d29cb7

Please sign in to comment.