Standardized the upsert and delete pattern across the repo.
This commit is contained in:
+140
@@ -0,0 +1,140 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO transactions (id, account_id, amount_cents, direction, date, description)\n VALUES ($1, $2, $3, $4, $5, $6)\n\t\tON CONFLICT (id) DO UPDATE SET\n account_id = EXCLUDED.account_id,\n\t\t\tamount_cents = EXCLUDED.amount_cents,\n\t\t\tdirection = EXCLUDED.direction,\n\t\t\tdate = EXCLUDED.date,\n\t\t\tdescription = EXCLUDED.description\n\t\tRETURNING WITH (OLD AS old_row, NEW AS new_row)\n\t\t\told_row.id AS \"old_id?\",\n\t\t\tCOALESCE(old_row.account_id, new_row.account_id) AS \"old_account_id!\",\n\t\t\tCOALESCE(old_row.amount_cents, new_row.amount_cents) AS \"old_amount_cents!\",\n\t\t\tCOALESCE(old_row.direction, new_row.direction) AS \"old_direction!\",\n\t\t\tCOALESCE(old_row.date, new_row.date) AS \"old_date!\",\n\t\t\tCOALESCE(old_row.description, new_row.description) AS \"old_description!\",\n\t\t\tnew_row.id AS \"id!\",\n new_row.account_id AS \"account_id!\",\n\t\t\tnew_row.amount_cents AS \"amount_cents!\",\n\t\t\tnew_row.direction AS \"direction!\",\n\t\t\tnew_row.date AS \"date!\",\n\t\t\tnew_row.description AS \"description!\"\n\t\t",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "old_id?",
|
||||
"type_info": "Uuid",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "transactions",
|
||||
"name": "id"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "old_account_id!",
|
||||
"type_info": "Uuid",
|
||||
"origin": "Expression"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "old_amount_cents!",
|
||||
"type_info": "Int8",
|
||||
"origin": "Expression"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "old_direction!",
|
||||
"type_info": "Text",
|
||||
"origin": "Expression"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "old_date!",
|
||||
"type_info": "Timestamptz",
|
||||
"origin": "Expression"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "old_description!",
|
||||
"type_info": "Text",
|
||||
"origin": "Expression"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "id!",
|
||||
"type_info": "Uuid",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "transactions",
|
||||
"name": "id"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "account_id!",
|
||||
"type_info": "Uuid",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "transactions",
|
||||
"name": "account_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "amount_cents!",
|
||||
"type_info": "Int8",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "transactions",
|
||||
"name": "amount_cents"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"name": "direction!",
|
||||
"type_info": "Text",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "transactions",
|
||||
"name": "direction"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"name": "date!",
|
||||
"type_info": "Timestamptz",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "transactions",
|
||||
"name": "date"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 11,
|
||||
"name": "description!",
|
||||
"type_info": "Text",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "transactions",
|
||||
"name": "description"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Int8",
|
||||
"Text",
|
||||
"Timestamptz",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "26a5b764d38ca78508087d1e793ae81530064a3ae661ff3c73c7cd686097aa81"
|
||||
}
|
||||
Reference in New Issue
Block a user