fix: the ordering test's setup sql compiles offline, and the head join names its app

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-09-16 09:57:43 +02:00
co-authored by Claude Opus 5
parent a96cf4b912
commit 05e4fb9de8
4 changed files with 12 additions and 12 deletions
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT a.id as app_id, av.id as version_id, dm.deployment_msg as deployment_msg,\n av.created_by as created_by, av.created_at as created_at\n FROM app a JOIN app_version av ON av.id = a.versions[array_upper(a.versions, 1)]\n LEFT JOIN deployment_metadata dm ON av.id = dm.app_version\n WHERE a.workspace_id = $1 AND a.path = $2",
"query": "SELECT a.id as app_id, av.id as version_id, dm.deployment_msg as deployment_msg,\n av.created_by as created_by, av.created_at as created_at\n FROM app a JOIN app_version av\n ON av.id = a.versions[array_upper(a.versions, 1)] AND av.app_id = a.id\n LEFT JOIN deployment_metadata dm ON av.id = dm.app_version\n WHERE a.workspace_id = $1 AND a.path = $2",
"describe": {
"columns": [
{
@@ -43,5 +43,5 @@
false
]
},
"hash": "1461a023390f674b0d2e286b506c0838c7cad23619984f44fb4c88d377acffc7"
"hash": "bd8ac169ad15346f28f561233fe340efd453512c1464a413af2393ab8bfea9ee"
}
+7 -8
View File
@@ -40,30 +40,29 @@ async fn test_app_head_follows_the_append_order_not_the_timestamps(
.await?;
assert!(res.status().is_success(), "{}", res.text().await?);
let first: i64 = sqlx::query_scalar!(
let first: i64 = sqlx::query_scalar(
"SELECT versions[array_upper(versions, 1)] FROM app
WHERE workspace_id = 'test-workspace' AND path = 'u/test-user/order_app'"
WHERE workspace_id = 'test-workspace' AND path = 'u/test-user/order_app'",
)
.fetch_one(&db)
.await?
.expect("the created app has a version");
.await?;
// The overlapping deploy: appended after `first`, so it is the version that
// landed, but stamped before it, so a timestamp sort puts it underneath.
let second: i64 = sqlx::query_scalar!(
let second: i64 = sqlx::query_scalar(
"INSERT INTO app_version (app_id, value, created_by, created_at, raw_app)
SELECT app_id, value, 'racer', created_at - interval '1 hour', raw_app
FROM app_version WHERE id = $1
RETURNING id",
first
)
.bind(first)
.fetch_one(&db)
.await?;
sqlx::query!(
sqlx::query(
"UPDATE app SET versions = array_append(versions, $1::bigint)
WHERE workspace_id = 'test-workspace' AND path = 'u/test-user/order_app'",
second
)
.bind(second)
.execute(&db)
.await?;
+2 -1
View File
@@ -1286,7 +1286,8 @@ async fn get_latest_version(
let row = sqlx::query!(
"SELECT a.id as app_id, av.id as version_id, dm.deployment_msg as deployment_msg,
av.created_by as created_by, av.created_at as created_at
FROM app a JOIN app_version av ON av.id = a.versions[array_upper(a.versions, 1)]
FROM app a JOIN app_version av
ON av.id = a.versions[array_upper(a.versions, 1)] AND av.app_id = a.id
LEFT JOIN deployment_metadata dm ON av.id = dm.app_version
WHERE a.workspace_id = $1 AND a.path = $2",
w_id,
@@ -6457,7 +6457,7 @@ var AppService = class {
* @param data.workspace
* @param data.path
* @param data.requestBody update app
* @returns string app updated
* @returns AppDeployed the path the app now lives at and the version this deploy wrote
* @throws ApiError
*/
static updateApp(data) {