Skip to content

Commit

Permalink
fix: fix dynamic config query (#1276)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
NathanFlurry committed Oct 29, 2024
1 parent 15eb44b commit 96155e2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/services/dynamic-config/src/ops/get_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@ pub async fn get_cluster_id(ctx: &OperationCtx, input: &Input) -> GlobalResult<O
sql_fetch_one!(
[ctx, (Uuid,)]
"
INSERT INTO config (id, cluster_id)
VALUES (1, $1)
ON CONFLICT (id) DO NOTHING
RETURNING cluster_id
WITH new_row AS (
INSERT INTO db_dynamic_config.config (id, cluster_id)
VALUES (1, $1)
ON CONFLICT (id) DO NOTHING
RETURNING cluster_id
)
SELECT cluster_id
FROM new_row
UNION ALL
SELECT cluster_id
FROM db_dynamic_config.config
WHERE NOT EXISTS (SELECT 1 FROM new_row)
",
default_cluster_id
)
Expand Down

0 comments on commit 96155e2

Please sign in to comment.