feat: ordering of queries

This commit is contained in:
Max Hohlfeld 2025-05-22 23:02:21 +02:00
parent e86d38d079
commit f1a22f83aa
23 changed files with 187 additions and 48 deletions

View File

@ -0,0 +1,26 @@
{
"db_name": "PostgreSQL",
"query": "SELECT * FROM clothing ORDER by name;",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Int4"
},
{
"ordinal": 1,
"name": "name",
"type_info": "Text"
}
],
"parameters": {
"Left": []
},
"nullable": [
false,
false
]
},
"hash": "03c789e902e84a8a3e753ac7d64c821e368b367eed085b3dc1bdc41cdf0ee6d2"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n event.id AS eventId,\n event.startTimestamp,\n event.endTimestamp,\n event.name,\n event.locationId,\n event.voluntaryWachhabender,\n event.voluntaryFuehrungsassistent,\n event.amountOfPosten,\n event.clothing,\n event.canceled,\n event.note,\n location.id,\n location.name AS locationName,\n location.areaId AS locationAreaId\n FROM event\n JOIN location ON event.locationId = location.id\n WHERE event.id = $1;\n ",
"query": "\n SELECT\n event.id AS eventId,\n event.startTimestamp,\n event.endTimestamp,\n event.name,\n event.locationId,\n event.voluntaryWachhabender,\n event.voluntaryFuehrungsassistent,\n event.amountOfPosten,\n event.clothing,\n event.canceled,\n event.note,\n location.id,\n location.name AS locationName,\n location.areaId AS locationAreaId,\n clothing.id AS clothingId,\n clothing.name AS clothingName\n FROM event\n JOIN location ON event.locationId = location.id\n JOIN clothing ON event.clothing = clothing.id\n WHERE starttimestamp::date = $1\n AND location.areaId = $2;\n ",
"describe": {
"columns": [
{
@ -46,7 +46,7 @@
{
"ordinal": 8,
"name": "clothing",
"type_info": "Text"
"type_info": "Int4"
},
{
"ordinal": 9,
@ -72,10 +72,21 @@
"ordinal": 13,
"name": "locationareaid",
"type_info": "Int4"
},
{
"ordinal": 14,
"name": "clothingid",
"type_info": "Int4"
},
{
"ordinal": 15,
"name": "clothingname",
"type_info": "Text"
}
],
"parameters": {
"Left": [
"Date",
"Int4"
]
},
@ -93,8 +104,10 @@
true,
false,
false,
false,
false,
false
]
},
"hash": "55a70284a5ddc7bff778ed1ea012b05b1daadbe41c77a8bd317f7fb17b7991cb"
"hash": "4ceb2c7e3d921c2718e75ba131eee1706e008b783deb687e04eba08f4b919ac8"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT * FROM location WHERE areaId = $1;",
"query": "SELECT * FROM location WHERE areaId = $1 ORDER by name;",
"describe": {
"columns": [
{
@ -30,5 +30,5 @@
false
]
},
"hash": "ea9f427b5d5a3e3c5f720d6bab2417cb3b42de0a5bf1d8b48b11a6e6275cc8e4"
"hash": "57742178247d76e67dd81af0873854d1c5d14e189e338ae55900a873146be99f"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT id,\n name,\n email,\n password,\n salt,\n role AS \"role: Role\",\n function AS \"function: UserFunction\",\n areaId,\n locked,\n lastLogin,\n receiveNotifications\n FROM user_;\n ",
"query": "\n SELECT id,\n name,\n email,\n password,\n salt,\n role AS \"role: Role\",\n function AS \"function: UserFunction\",\n areaId,\n locked,\n lastLogin,\n receiveNotifications\n FROM user_\n ORDER BY id;\n ",
"describe": {
"columns": [
{
@ -105,5 +105,5 @@
false
]
},
"hash": "5573e93ccc0b6a5ecc6183a5d5c589ccd58f786e70a3ff1efa662085c2035156"
"hash": "61ae80bcf916ac62220ffd16eb0be5e37e086f9f5b753d451725ea429ab84fbc"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT id,\n name,\n email,\n password,\n salt,\n role AS \"role: Role\",\n function AS \"function: UserFunction\",\n areaId,\n locked,\n lastLogin,\n receiveNotifications\n FROM user_\n WHERE areaId = $1;\n ",
"query": "\n SELECT id,\n name,\n email,\n password,\n salt,\n role AS \"role: Role\",\n function AS \"function: UserFunction\",\n areaId,\n locked,\n lastLogin,\n receiveNotifications\n FROM user_\n WHERE areaId = $1\n ORDER BY id;\n ",
"describe": {
"columns": [
{
@ -107,5 +107,5 @@
false
]
},
"hash": "483ad933fa1e935058cbe42b7ff083ceee80f74564ee3e8b7da6ab57e906368b"
"hash": "6260f72ba85714e8529af2c4f3da77cf67556af87c72997b68fa8bd8bcae62a8"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n event.id AS eventId,\n event.startTimestamp,\n event.endTimestamp,\n event.name,\n event.locationId,\n event.voluntaryWachhabender,\n event.voluntaryFuehrungsassistent,\n event.amountOfPosten,\n event.clothing,\n event.canceled,\n event.note,\n location.id,\n location.name AS locationName,\n location.areaId AS locationAreaId\n FROM event\n JOIN location ON event.locationId = location.id\n WHERE starttimestamp::date = $1\n AND location.areaId = $2;\n ",
"query": "\n SELECT\n event.id AS eventId,\n event.startTimestamp,\n event.endTimestamp,\n event.name,\n event.locationId,\n event.voluntaryWachhabender,\n event.voluntaryFuehrungsassistent,\n event.amountOfPosten,\n event.clothing,\n event.canceled,\n event.note,\n location.id,\n location.name AS locationName,\n location.areaId AS locationAreaId,\n clothing.id AS clothingId,\n clothing.name AS clothingName\n FROM event\n JOIN location ON event.locationId = location.id\n JOIN clothing ON event.clothing = clothing.id\n WHERE event.id = $1;\n ",
"describe": {
"columns": [
{
@ -46,7 +46,7 @@
{
"ordinal": 8,
"name": "clothing",
"type_info": "Text"
"type_info": "Int4"
},
{
"ordinal": 9,
@ -72,11 +72,20 @@
"ordinal": 13,
"name": "locationareaid",
"type_info": "Int4"
},
{
"ordinal": 14,
"name": "clothingid",
"type_info": "Int4"
},
{
"ordinal": 15,
"name": "clothingname",
"type_info": "Text"
}
],
"parameters": {
"Left": [
"Date",
"Int4"
]
},
@ -94,8 +103,10 @@
true,
false,
false,
false,
false,
false
]
},
"hash": "d4a8fe79186f648212fb270323942e60edd5163b6463c2f0ef22baaf8be7bcd5"
"hash": "6dc18993de451d1e0aa4080f00f46ce3339e020922b9ef130c4289b080a2af7d"
}

View File

@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE clothing SET name = $1 WHERE id = $2;",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Text",
"Int4"
]
},
"nullable": []
},
"hash": "770344caf4f209a95fd26cb778e7dfbb249c8edc24a0981c7c0e5bb7854f7fde"
}

View File

@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO clothing (name) VALUES ($1) RETURNING id;",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Int4"
}
],
"parameters": {
"Left": [
"Text"
]
},
"nullable": [
false
]
},
"hash": "8331b42d55c64827a0382b830e453158cbe3fc7919fec93c9ca03dcf570c9e9d"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT * FROM area ORDER by id",
"query": "SELECT * FROM area ORDER by name",
"describe": {
"columns": [
{
@ -22,5 +22,5 @@
false
]
},
"hash": "7f6c89117e8d4249e032235d03d264c3d5d47bd119c563237486cf47e402ae2e"
"hash": "852293a7ffbde434401e3b45847275b4992b509da4148055cbe65ca26526f3ca"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT * FROM location",
"query": "SELECT * FROM location ORDER BY name;",
"describe": {
"columns": [
{
@ -28,5 +28,5 @@
false
]
},
"hash": "2d9f2d0728983dfac09f6649da74aa5659072539a8f222b8ae202786ce958c37"
"hash": "9b3e6609e33be0e428d759f1294d5804c9463f06f7747bf4ea04599da9b4b531"
}

View File

@ -0,0 +1,28 @@
{
"db_name": "PostgreSQL",
"query": "SELECT * FROM clothing WHERE id = $1;",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Int4"
},
{
"ordinal": 1,
"name": "name",
"type_info": "Text"
}
],
"parameters": {
"Left": [
"Int4"
]
},
"nullable": [
false,
false
]
},
"hash": "9e7ed80577cdceb87b5e5c4903aeadb7c0aea19b94f43828d97a26446ddd1a81"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n user_.id AS userId,\n user_.name,\n user_.email,\n user_.password,\n user_.salt,\n user_.role AS \"role: Role\",\n function AS \"function: UserFunction\",\n user_.areaId,\n user_.locked,\n user_.lastLogin,\n user_.receiveNotifications,\n area.id,\n area.name AS areaName\n FROM user_\n JOIN area ON user_.areaId = area.id\n ",
"query": "\n SELECT\n user_.id AS userId,\n user_.name,\n user_.email,\n user_.password,\n user_.salt,\n user_.role AS \"role: Role\",\n function AS \"function: UserFunction\",\n user_.areaId,\n user_.locked,\n user_.lastLogin,\n user_.receiveNotifications,\n area.id,\n area.name AS areaName\n FROM user_\n JOIN area ON user_.areaId = area.id\n ORDER BY userId;\n ",
"describe": {
"columns": [
{
@ -117,5 +117,5 @@
false
]
},
"hash": "a7f6e57733c655534c3ae6379b8616fc3aa63ce322cc2d718f4b4e4e23903a61"
"hash": "aad65af88315c7c358c8d72c466139d8a0bef32d03c4dd8cd1e8c2316224da79"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT * FROM vehicle;",
"query": "SELECT * FROM vehicle ORDER BY radioCallName;",
"describe": {
"columns": [
{
@ -28,5 +28,5 @@
false
]
},
"hash": "5b87f4da0924338da1a30d7b74711d8073f6d62cf30a42381484846f0917bc33"
"hash": "b145ac6b3c43aa24082ca9d6642dc36e745b7b1e633b94cb61e980a5e0fc60b5"
}

View File

@ -12,7 +12,7 @@
"Bool",
"Bool",
"Int2",
"Text",
"Int4",
"Text"
]
},

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT location.id AS locationId, location.name, location.areaId, area.id, area.name AS areaName FROM location JOIN area ON location.areaId = area.id WHERE areaId = $1;",
"query": "SELECT location.id AS locationId, location.name, location.areaId, area.id, area.name AS areaName FROM location JOIN area ON location.areaId = area.id WHERE areaId = $1 ORDER by name;",
"describe": {
"columns": [
{
@ -42,5 +42,5 @@
false
]
},
"hash": "70850ec3f7c519c1fc104fead6a44d07ba76023567bc6ea0eec2267d1c592479"
"hash": "b43b6a9e1bd8f05c79368115aa5e59b22a5d275c91c1aae39fbc17ecf9297efc"
}

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT location.id AS locationId, location.name, location.areaId, area.id, area.name AS areaName FROM location JOIN area ON location.areaId = area.id;",
"query": "SELECT location.id AS locationId, location.name, location.areaId, area.id, area.name AS areaName FROM location JOIN area ON location.areaId = area.id ORDER BY name;",
"describe": {
"columns": [
{
@ -40,5 +40,5 @@
false
]
},
"hash": "f94d7fe59a2d4b7d246711a796571367172bce9446b9fb1e7ba057917a98d958"
"hash": "c9a989d3b08f4147643a540aecbb0d6275cb71ff217359f87467a46b32648ea7"
}

View File

@ -12,7 +12,7 @@
"Bool",
"Bool",
"Int2",
"Text",
"Int4",
"Text",
"Int4"
]

View File

@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM clothing WHERE id = $1;",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int4"
]
},
"nullable": []
},
"hash": "fc95525b2ce9e74c243c222a4051fb072d4112c082681b7ce83648eb7d5bd23a"
}

View File

@ -25,7 +25,7 @@ impl Area {
}
pub async fn read_all(pool: &PgPool) -> Result<Vec<Area>> {
let records = query_as!(Area, "SELECT * FROM area ORDER by id")
let records = query_as!(Area, "SELECT * FROM area ORDER by name")
.fetch_all(pool)
.await?;

View File

@ -23,7 +23,7 @@ impl Clothing {
}
pub async fn read_all(pool: &PgPool) -> Result<Vec<Clothing>> {
let records = query!("SELECT * FROM clothing ORDER by id;").fetch_all(pool).await?;
let records = query!("SELECT * FROM clothing ORDER by name;").fetch_all(pool).await?;
let clothing_options = records
.into_iter()

View File

@ -26,9 +26,12 @@ impl Location {
}
pub async fn read_by_area(pool: &PgPool, area_id: i32) -> Result<Vec<Location>> {
let records = query!("SELECT * FROM location WHERE areaId = $1;", area_id)
.fetch_all(pool)
.await?;
let records = query!(
"SELECT * FROM location WHERE areaId = $1 ORDER by name;",
area_id
)
.fetch_all(pool)
.await?;
let locations = records
.iter()
@ -44,7 +47,7 @@ impl Location {
}
pub async fn read_by_area_including_area(pool: &PgPool, area_id: i32) -> Result<Vec<Location>> {
let records = query!("SELECT location.id AS locationId, location.name, location.areaId, area.id, area.name AS areaName FROM location JOIN area ON location.areaId = area.id WHERE areaId = $1;", area_id)
let records = query!("SELECT location.id AS locationId, location.name, location.areaId, area.id, area.name AS areaName FROM location JOIN area ON location.areaId = area.id WHERE areaId = $1 ORDER by name;", area_id)
.fetch_all(pool)
.await?;
@ -56,7 +59,7 @@ impl Location {
area_id: lr.areaid,
area: Some(Area {
id: lr.id,
name: lr.areaname.to_string()
name: lr.areaname.to_string(),
}),
})
.collect();
@ -65,7 +68,9 @@ impl Location {
}
pub async fn read_all(pool: &PgPool) -> Result<Vec<Location>> {
let records = query!("SELECT * FROM location").fetch_all(pool).await?;
let records = query!("SELECT * FROM location ORDER BY name;")
.fetch_all(pool)
.await?;
let locations = records
.iter()
@ -81,7 +86,7 @@ impl Location {
}
pub async fn read_all_including_area(pool: &PgPool) -> Result<Vec<Location>> {
let records = query!("SELECT location.id AS locationId, location.name, location.areaId, area.id, area.name AS areaName FROM location JOIN area ON location.areaId = area.id;")
let records = query!("SELECT location.id AS locationId, location.name, location.areaId, area.id, area.name AS areaName FROM location JOIN area ON location.areaId = area.id ORDER BY name;")
.fetch_all(pool)
.await?;
@ -107,11 +112,11 @@ impl Location {
.await?;
let location = record.map(|r| Location {
id: r.id,
name: r.name,
area_id: r.areaid,
area: None,
});
id: r.id,
name: r.name,
area_id: r.areaid,
area: None,
});
Ok(location)
}

View File

@ -161,7 +161,8 @@ impl User {
locked,
lastLogin,
receiveNotifications
FROM user_;
FROM user_
ORDER BY id;
"#,
)
.fetch_all(pool)
@ -207,6 +208,7 @@ impl User {
area.name AS areaName
FROM user_
JOIN area ON user_.areaId = area.id
ORDER BY userId;
"#
)
.fetch_all(pool)
@ -251,7 +253,8 @@ impl User {
lastLogin,
receiveNotifications
FROM user_
WHERE areaId = $1;
WHERE areaId = $1
ORDER BY id;
"#,
area_id
)

View File

@ -22,7 +22,9 @@ impl Vehicle {
}
pub async fn read_all(pool: &PgPool) -> Result<Vec<Vehicle>> {
let records = query!("SELECT * FROM vehicle;").fetch_all(pool).await?;
let records = query!("SELECT * FROM vehicle ORDER BY radioCallName;")
.fetch_all(pool)
.await?;
let vehicles = records
.into_iter()
@ -42,10 +44,10 @@ impl Vehicle {
.await?;
let vehicle = record.map(|v| Vehicle {
id: v.id,
radio_call_name: v.radiocallname,
station: v.station,
});
id: v.id,
radio_call_name: v.radiocallname,
station: v.station,
});
Ok(vehicle)
}