fix insert err return & timestamp formatting
This commit is contained in:
parent
df398dab1a
commit
d99db63940
@ -3,4 +3,3 @@ dbentity
|
||||
id : integer
|
||||
parent_id : bigint
|
||||
type : varchar(255)
|
||||
}
|
@ -2,4 +2,3 @@ dbrole
|
||||
description : text
|
||||
id : integer
|
||||
name : varchar
|
||||
}
|
@ -3,4 +3,3 @@ dbtableaccess
|
||||
id : integer
|
||||
tableaccess : varchar(255)
|
||||
userrolerestrictions : varchar(255)
|
||||
}
|
@ -2,4 +2,3 @@ dbuser
|
||||
id : integer
|
||||
login : varchar(255)|comment
|
||||
password : varchar(255)
|
||||
}
|
@ -5,4 +5,3 @@ dbuserrole
|
||||
enddate : timestamp without time zone
|
||||
id : integer
|
||||
startdate : timestamp without time zone
|
||||
}
|
@ -2,4 +2,3 @@ testtype
|
||||
detail : varchar(255)
|
||||
id : integer
|
||||
name : varchar(255)
|
||||
}
|
6
pg.go
6
pg.go
@ -329,8 +329,8 @@ func (t *TableInfo) Insert(record AssRow) (int, error) {
|
||||
values += FormatForSQL(t.Columns[key], element) + ","
|
||||
}
|
||||
|
||||
t.db.conn.QueryRow("INSERT INTO " + t.Name + "(" + removeLastChar(columns) + ") VALUES (" + removeLastChar(values) + ") RETURNING id").Scan(&id)
|
||||
return id, nil
|
||||
err = t.db.conn.QueryRow("INSERT INTO " + t.Name + "(" + removeLastChar(columns) + ") VALUES (" + removeLastChar(values) + ") RETURNING id").Scan(&id)
|
||||
return id, err
|
||||
}
|
||||
|
||||
func (t *TableInfo) Update(record AssRow) error {
|
||||
@ -523,7 +523,7 @@ func FormatForSQL(datatype string, value interface{}) string {
|
||||
if !strings.Contains(datatype, "char") && len(strval) == 0 {
|
||||
return "NULL"
|
||||
}
|
||||
if strings.Contains(datatype, "char") || strings.Contains(datatype, "date") {
|
||||
if strings.Contains(datatype, "char") || strings.Contains(datatype, "date") || strings.Contains(datatype, "timestamp") {
|
||||
return fmt.Sprint(pq.QuoteLiteral(strval))
|
||||
}
|
||||
return fmt.Sprint(strval)
|
||||
|
101
schema.json
101
schema.json
@ -1,13 +1,4 @@
|
||||
[
|
||||
{
|
||||
"name": "computer",
|
||||
"columns": {
|
||||
"description": "varchar(1000)",
|
||||
"id": "integer",
|
||||
"name": "varchar(255)|comment",
|
||||
"os": "varchar(255)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dbentity",
|
||||
"columns": {
|
||||
@ -53,61 +44,6 @@
|
||||
"startdate": "timestamp without time zone"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "entity",
|
||||
"columns": {
|
||||
"enddate": "date",
|
||||
"id": "integer",
|
||||
"name": "varchar(255)",
|
||||
"startdate": "date",
|
||||
"type": "varchar(255)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "person",
|
||||
"columns": {
|
||||
"email": "varchar(255)",
|
||||
"firstname": "varchar(255)",
|
||||
"id": "integer",
|
||||
"mobile": "varchar(255)",
|
||||
"name": "varchar(255)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "software",
|
||||
"columns": {
|
||||
"company": "varchar(255)",
|
||||
"description": "varchar(1000)",
|
||||
"id": "integer",
|
||||
"licenseend": "date",
|
||||
"name": "varchar(255)|comment",
|
||||
"support": "varchar(255)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "software_computer",
|
||||
"columns": {
|
||||
"computer_id": "integer",
|
||||
"id": "integer",
|
||||
"software_id": "integer"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "test",
|
||||
"columns": {
|
||||
"description": "varchar(1000)",
|
||||
"enddate": "timestamp without time zone",
|
||||
"floatvalue": "double precision",
|
||||
"id": "integer",
|
||||
"intvalue": "integer",
|
||||
"latitude": "double precision|map",
|
||||
"longitude": "double precision|map",
|
||||
"name": "varchar(255)|comment",
|
||||
"price": "money",
|
||||
"startdate": "timestamp without time zone",
|
||||
"testtype_id": "integer"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "testtype",
|
||||
"columns": {
|
||||
@ -115,42 +51,5 @@
|
||||
"id": "integer",
|
||||
"name": "varchar(255)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "timetracking",
|
||||
"columns": {
|
||||
"afternoon_entity_id": "integer",
|
||||
"comment": "varchar(255)",
|
||||
"day": "date",
|
||||
"id": "integer",
|
||||
"morning_entity_id": "integer"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "surveyquestion",
|
||||
"columns": {
|
||||
"type": "integer",
|
||||
"label": "varchar(1000)",
|
||||
"responses": "varchar(1000)",
|
||||
"id": "integer",
|
||||
"votes": "integer"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "surveyresponse",
|
||||
"columns": {
|
||||
"surveyuser_id": "integer",
|
||||
"surveyquestion_id": "varchar(255)",
|
||||
"response": "varchar(1000)",
|
||||
"id": "integer"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "surveyuser",
|
||||
"columns": {
|
||||
"voted": "bool",
|
||||
"code": "varchar(255)",
|
||||
"id": "integer"
|
||||
}
|
||||
}
|
||||
]
|
77
schema.puml
77
schema.puml
@ -1,13 +1,6 @@
|
||||
@startuml
|
||||
|
||||
|
||||
entity computer {
|
||||
description : varchar(1000)
|
||||
id : integer
|
||||
name : varchar(255)|comment
|
||||
os : varchar(255)
|
||||
}
|
||||
|
||||
entity dbentity {
|
||||
description : text
|
||||
id : integer
|
||||
@ -43,90 +36,24 @@ entity dbuserrole {
|
||||
startdate : timestamp without time zone
|
||||
}
|
||||
|
||||
entity entity {
|
||||
enddate : date
|
||||
id : integer
|
||||
name : varchar(255)
|
||||
startdate : date
|
||||
type : varchar(255)
|
||||
}
|
||||
|
||||
entity person {
|
||||
email : varchar(255)
|
||||
firstname : varchar(255)
|
||||
id : integer
|
||||
mobile : varchar(255)
|
||||
name : varchar(255)
|
||||
}
|
||||
|
||||
entity software {
|
||||
company : varchar(255)
|
||||
description : varchar(1000)
|
||||
id : integer
|
||||
licenseend : date
|
||||
name : varchar(255)|comment
|
||||
support : varchar(255)
|
||||
}
|
||||
|
||||
entity software_computer {
|
||||
computer_id : integer
|
||||
id : integer
|
||||
software_id : integer
|
||||
}
|
||||
|
||||
entity test {
|
||||
description : varchar(1000)
|
||||
enddate : timestamp without time zone
|
||||
floatvalue : double precision
|
||||
id : integer
|
||||
intvalue : integer
|
||||
latitude : double precision|map
|
||||
longitude : double precision|map
|
||||
name : varchar(255)|comment
|
||||
price : money
|
||||
startdate : timestamp without time zone
|
||||
testtype_id : integer
|
||||
}
|
||||
|
||||
entity testtype {
|
||||
detail : varchar(255)
|
||||
id : integer
|
||||
name : varchar(255)
|
||||
}
|
||||
|
||||
entity timetracking {
|
||||
afternoon_entity_id : integer
|
||||
comment : varchar(255)
|
||||
day : date
|
||||
id : integer
|
||||
morning_entity_id : integer
|
||||
person_id : integer
|
||||
}
|
||||
|
||||
|
||||
|
||||
dbentity ||..|| parent
|
||||
|
||||
dbtableaccess ||..|| dbrole
|
||||
|
||||
dbuserrole ||..|| dbuser
|
||||
|
||||
dbuserrole ||..|| dbentity
|
||||
|
||||
dbuserrole ||..|| dbrole
|
||||
|
||||
dbuserrole ||..|| dbuser
|
||||
|
||||
software_computer ||..|| computer
|
||||
|
||||
software_computer ||..|| software
|
||||
|
||||
test ||..|| testtype
|
||||
|
||||
timetracking ||..|| entity
|
||||
|
||||
timetracking ||..|| person
|
||||
|
||||
timetracking ||..|| entity
|
||||
|
||||
|
||||
@enduml
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user