json bug fixed
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
// src/table_definition/handlers/post_table_definition.rs
|
// src/table_definition/handlers/post_table_definition.rs
|
||||||
use tonic::Status;
|
use tonic::Status;
|
||||||
use sqlx::{PgPool, types::Json};
|
use sqlx::PgPool;
|
||||||
|
use serde_json::json;
|
||||||
use common::proto::multieko2::table_definition::{PostTableDefinitionRequest, TableDefinitionResponse};
|
use common::proto::multieko2::table_definition::{PostTableDefinitionRequest, TableDefinitionResponse};
|
||||||
|
|
||||||
// Validate SQL identifiers
|
// Validate SQL identifiers
|
||||||
@@ -58,8 +59,8 @@ pub async fn post_table_definition(
|
|||||||
VALUES ($1, $2, $3, $4)"#,
|
VALUES ($1, $2, $3, $4)"#,
|
||||||
"system", // Or get from auth context
|
"system", // Or get from auth context
|
||||||
&table_name,
|
&table_name,
|
||||||
Json(&columns),
|
json!(columns), // Use serde_json::json! to convert Vec<String> to JsonValue
|
||||||
Json(&indexes)
|
json!(indexes) // Use serde_json::json! to convert Vec<String> to JsonValue
|
||||||
)
|
)
|
||||||
.execute(db_pool)
|
.execute(db_pool)
|
||||||
.await
|
.await
|
||||||
@@ -78,7 +79,8 @@ pub async fn post_table_definition(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| Status::internal(format!("Table creation failed: {}", e)))?;
|
.map_err(|e| Status::internal(format!("Table creation failed: {}", e)))?;
|
||||||
|
|
||||||
for sql in index_sql {
|
// Iterate over a reference to index_sql to avoid moving it
|
||||||
|
for sql in &index_sql {
|
||||||
sqlx::query(&sql)
|
sqlx::query(&sql)
|
||||||
.execute(db_pool)
|
.execute(db_pool)
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in New Issue
Block a user