Prepared queries

This commit is contained in:
StNicolay 2024-08-04 13:51:19 +03:00
parent ea5c65b6e5
commit 8d297fffdf
Signed by: StNicolay
GPG Key ID: 9693D04DCD962B0D
6 changed files with 67 additions and 10 deletions

View File

@ -0,0 +1,28 @@
{
"db_name": "PostgreSQL",
"query": "SELECT user_id, hashed_password FROM users WHERE username = $1 OR email = $1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "user_id",
"type_info": "Int4"
},
{
"ordinal": 1,
"name": "hashed_password",
"type_info": "Bytea"
}
],
"parameters": {
"Left": [
"Text"
]
},
"nullable": [
false,
false
]
},
"hash": "20af817890cb184e17d193e18132796e02e5e7352542f507acda25e9cd6cfc61"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE users SET username = $2, email = $3 WHERE user_id = $1 RETURNING *",
"query": "UPDATE users SET username = $2, email = $3 WHERE user_id = $1 RETURNING user_id, username, email",
"describe": {
"columns": [
{
@ -32,5 +32,5 @@
false
]
},
"hash": "347a486f9ea5183b1c4c16234a1833ea61970ea7f901dd57c0715ae3dbddd164"
"hash": "70a68acb301745ef393185c2bef92627648a6e419303adb40f56c09d55291cbd"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO users(username, email) VALUES ($1, $2) RETURNING user_id",
"query": "INSERT INTO users(username, email, hashed_password) VALUES ($1, $2, $3) RETURNING user_id",
"describe": {
"columns": [
{
@ -12,12 +12,13 @@
"parameters": {
"Left": [
"Varchar",
"Varchar"
"Varchar",
"Bytea"
]
},
"nullable": [
false
]
},
"hash": "9602875e192fd321f3a773aa7eb5145cb0d1e7f31def733fd11394e9ad6c0d21"
"hash": "879bdad048c3151e54ee70a2c316d90dcc1a0f50a1df2c7681917a2890d082cf"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT\n user_id, username, email\nFROM\n users\nORDER BY\n GREATEST (\n similarity (email, $1),\n similarity (username, $1)\n ) DESC",
"query": "SELECT\n user_id, username, email, \n GREATEST (\n similarity (email, $1),\n similarity (username, $1)\n ) as \"similarity!\"\nFROM\n users\nORDER BY\n \"similarity!\" DESC",
"describe": {
"columns": [
{
@ -17,6 +17,11 @@
"ordinal": 2,
"name": "email",
"type_info": "Varchar"
},
{
"ordinal": 3,
"name": "similarity!",
"type_info": "Float4"
}
],
"parameters": {
@ -27,8 +32,9 @@
"nullable": [
false,
false,
false
false,
null
]
},
"hash": "61a26b3321bb5b58a0b90e61b2cdcacfb46a03eb0c0a89839c9b3eff53cb7e56"
"hash": "8d8bf29e632723ba48a19ea52a8466424f7628e84df17178bf26eaca1cc99aca"
}

View File

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "SELECT EXISTS(SELECT user_id FROM users WHERE user_id = $1)",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "exists",
"type_info": "Bool"
}
],
"parameters": {
"Left": [
"Int4"
]
},
"nullable": [
null
]
},
"hash": "a04a4e8d3a394883a2f1052074bd43fcadafa0c1ba66f36ac49fc54b5c4150b3"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT\n f.folder_id,\n owner_id,\n folder_name,\n created_at\nFROM\n folders f\n JOIN permissions p ON f.folder_id = p.folder_id\nWHERE\n parent_folder_id = $1\n AND p.user_id = $2",
"query": "SELECT\n f.folder_id,\n owner_id,\n folder_name,\n created_at\nFROM\n folders f\n LEFT JOIN permissions p ON f.folder_id = p.folder_id\nWHERE\n parent_folder_id = $1\n AND (p.user_id = $2 OR f.owner_id = $2)",
"describe": {
"columns": [
{
@ -37,5 +37,5 @@
false
]
},
"hash": "b11a87b3b9f6289e831b1f0cb0e8f35283687a9b13d050ac15f16e2a8cec046f"
"hash": "ef707c0f6d2ef0d66e71929167b5c82bb8bf923736e6c797711bc3124f0693bc"
}