@@ -1233,55 +1233,58 @@ impl ___Type for QueryType {
1233
1233
f. push ( collection_entrypoint) ;
1234
1234
1235
1235
// Add single record query by primary key if the table has a primary key
1236
+ // and the primary key types are supported (int, bigint, uuid, string)
1236
1237
if let Some ( primary_key) = table. primary_key ( ) {
1237
- let node_type = NodeType {
1238
- table : Arc :: clone ( table) ,
1239
- fkey : None ,
1240
- reverse_reference : None ,
1241
- schema : Arc :: clone ( & self . schema ) ,
1242
- } ;
1243
-
1244
- // Create arguments for each primary key column
1245
- let mut pk_args = Vec :: new ( ) ;
1246
- for col_name in & primary_key. column_names {
1247
- if let Some ( col) = table. columns . iter ( ) . find ( |c| & c. name == col_name) {
1248
- let col_type = sql_column_to_graphql_type ( col, & self . schema )
1249
- . ok_or_else ( || {
1250
- format ! (
1251
- "Could not determine GraphQL type for column {}" ,
1252
- col_name
1253
- )
1254
- } )
1255
- . unwrap_or_else ( |_| __Type:: Scalar ( Scalar :: String ( None ) ) ) ;
1256
-
1257
- // Use graphql_column_field_name to convert snake_case to camelCase if needed
1258
- let arg_name = self . schema . graphql_column_field_name ( col) ;
1259
-
1260
- pk_args. push ( __InputValue {
1261
- name_ : arg_name,
1262
- type_ : __Type:: NonNull ( NonNullType {
1263
- type_ : Box :: new ( col_type) ,
1264
- } ) ,
1265
- description : Some ( format ! ( "The record's `{}` value" , col_name) ) ,
1266
- default_value : None ,
1267
- sql_type : Some ( NodeSQLType :: Column ( Arc :: clone ( col) ) ) ,
1268
- } ) ;
1238
+ if table. has_supported_pk_types_for_by_pk ( ) {
1239
+ let node_type = NodeType {
1240
+ table : Arc :: clone ( table) ,
1241
+ fkey : None ,
1242
+ reverse_reference : None ,
1243
+ schema : Arc :: clone ( & self . schema ) ,
1244
+ } ;
1245
+
1246
+ // Create arguments for each primary key column
1247
+ let mut pk_args = Vec :: new ( ) ;
1248
+ for col_name in & primary_key. column_names {
1249
+ if let Some ( col) = table. columns . iter ( ) . find ( |c| & c. name == col_name) {
1250
+ let col_type = sql_column_to_graphql_type ( col, & self . schema )
1251
+ . ok_or_else ( || {
1252
+ format ! (
1253
+ "Could not determine GraphQL type for column {}" ,
1254
+ col_name
1255
+ )
1256
+ } )
1257
+ . unwrap_or_else ( |_| __Type:: Scalar ( Scalar :: String ( None ) ) ) ;
1258
+
1259
+ // Use graphql_column_field_name to convert snake_case to camelCase if needed
1260
+ let arg_name = self . schema . graphql_column_field_name ( col) ;
1261
+
1262
+ pk_args. push ( __InputValue {
1263
+ name_ : arg_name,
1264
+ type_ : __Type:: NonNull ( NonNullType {
1265
+ type_ : Box :: new ( col_type) ,
1266
+ } ) ,
1267
+ description : Some ( format ! ( "The record's `{}` value" , col_name) ) ,
1268
+ default_value : None ,
1269
+ sql_type : Some ( NodeSQLType :: Column ( Arc :: clone ( col) ) ) ,
1270
+ } ) ;
1271
+ }
1269
1272
}
1270
- }
1271
1273
1272
- let pk_entrypoint = __Field {
1273
- name_ : format ! ( "{}ByPk" , lowercase_first_letter( table_base_type_name) ) ,
1274
- type_ : __Type:: Node ( node_type) ,
1275
- args : pk_args,
1276
- description : Some ( format ! (
1277
- "Retrieve a record of type `{}` by its primary key" ,
1278
- table_base_type_name
1279
- ) ) ,
1280
- deprecation_reason : None ,
1281
- sql_type : None ,
1282
- } ;
1274
+ let pk_entrypoint = __Field {
1275
+ name_ : format ! ( "{}ByPk" , lowercase_first_letter( table_base_type_name) ) ,
1276
+ type_ : __Type:: Node ( node_type) ,
1277
+ args : pk_args,
1278
+ description : Some ( format ! (
1279
+ "Retrieve a record of type `{}` by its primary key" ,
1280
+ table_base_type_name
1281
+ ) ) ,
1282
+ deprecation_reason : None ,
1283
+ sql_type : None ,
1284
+ } ;
1283
1285
1284
- f. push ( pk_entrypoint) ;
1286
+ f. push ( pk_entrypoint) ;
1287
+ }
1285
1288
}
1286
1289
}
1287
1290
}
@@ -3443,7 +3446,7 @@ impl FromStr for FilterOp {
3443
3446
"contains" => Ok ( Self :: Contains ) ,
3444
3447
"containedBy" => Ok ( Self :: ContainedBy ) ,
3445
3448
"overlaps" => Ok ( Self :: Overlap ) ,
3446
- _ => Err ( "Invalid filter operation" . to_string ( ) ) ,
3449
+ other => Err ( format ! ( "Invalid filter operation: {}" , other ) ) ,
3447
3450
}
3448
3451
}
3449
3452
}
0 commit comments