@@ -411,25 +411,25 @@ func (db *DB) TableSchema(params map[string]any, table string, dbName string, ex
411411 } else if contains (_pg_drivers , _driver ) {
412412 user_id := int (params ["user" ].(map [string ]interface {})["user_id" ].(float64 ))
413413 _query := fmt .Sprintf (`SELECT
414- c.ordinal_position - 1 AS cid,
415- c.column_name AS name,
416- c.data_type AS type,
417- (c.is_nullable = 'NO') AS notnull,
418- c.column_default AS dflt_value,
419- CASE WHEN kcu.column_name IS NOT NULL THEN 1 ELSE 0 END AS pk
420- FROM information_schema.columns c
421- LEFT JOIN information_schema.key_column_usage kcu
422- ON c.table_name = kcu.table_name
423- AND c.column_name = kcu.column_name
424- AND kcu.constraint_name IN (
425- SELECT constraint_name
426- FROM information_schema.table_constraints
427- WHERE table_name = '%s'
428- AND constraint_type = 'PRIMARY KEY'
429- )
430- WHERE c.table_name = '%s'
431- ORDER BY c.ordinal_position;
432- ` , table , table )
414+ c.ordinal_position - 1 AS cid,
415+ c.column_name AS name,
416+ c.data_type AS type,
417+ (c.is_nullable = 'NO') AS notnull,
418+ c.column_default AS dflt_value,
419+ CASE WHEN kcu.column_name IS NOT NULL THEN 1 ELSE 0 END AS pk
420+ FROM information_schema.columns c
421+ LEFT JOIN information_schema.key_column_usage kcu
422+ ON c.table_name = kcu.table_name
423+ AND c.column_name = kcu.column_name
424+ AND kcu.constraint_name IN (
425+ SELECT constraint_name
426+ FROM information_schema.table_constraints
427+ WHERE table_name = '%s'
428+ AND constraint_type = 'PRIMARY KEY'
429+ )
430+ WHERE c.table_name = '%s'
431+ ORDER BY c.ordinal_position;
432+ ` , table , table )
433433 //fmt.Println(table, _query)
434434 _aux_data := []map [string ]interface {}{}
435435 _aux_data_fk := map [string ]interface {}{}
@@ -438,37 +438,37 @@ ORDER BY c.ordinal_position;
438438 return nil , false , err
439439 }
440440 _query = fmt .Sprintf (`WITH foreign_keys AS (
441- SELECT
442- rc.constraint_name AS fk_name,
443- tc.table_name AS table_name,
444- kcu.column_name AS "from",
445- ccu.table_name AS "to",
446- ccu.column_name AS to_column,
447- rc.update_rule AS on_update,
448- rc.delete_rule AS on_delete,
449- kcu.ordinal_position AS seq
450- FROM information_schema.referential_constraints rc
451- JOIN information_schema.table_constraints tc
452- ON rc.constraint_name = tc.constraint_name
453- AND rc.constraint_schema = tc.constraint_schema
454- JOIN information_schema.key_column_usage kcu
455- ON kcu.constraint_name = rc.constraint_name
456- AND kcu.constraint_schema = rc.constraint_schema
457- JOIN information_schema.constraint_column_usage ccu
458- ON ccu.constraint_name = rc.constraint_name
459- AND ccu.constraint_schema = rc.constraint_schema
460- WHERE tc.table_name = '%s'
461- )
462- SELECT
463- ROW_NUMBER() OVER () - 1 AS id,
464- seq,
465- table_name AS parent_table,
466- "from",
467- "to",
468- on_update,
469- on_delete,
470- 'NONE' AS match
471- FROM foreign_keys;` , table )
441+ SELECT
442+ rc.constraint_name AS fk_name,
443+ tc.table_name AS table_name,
444+ kcu.column_name AS "from",
445+ ccu.table_name AS "to",
446+ ccu.column_name AS to_column,
447+ rc.update_rule AS on_update,
448+ rc.delete_rule AS on_delete,
449+ kcu.ordinal_position AS seq
450+ FROM information_schema.referential_constraints rc
451+ JOIN information_schema.table_constraints tc
452+ ON rc.constraint_name = tc.constraint_name
453+ AND rc.constraint_schema = tc.constraint_schema
454+ JOIN information_schema.key_column_usage kcu
455+ ON kcu.constraint_name = rc.constraint_name
456+ AND kcu.constraint_schema = rc.constraint_schema
457+ JOIN information_schema.constraint_column_usage ccu
458+ ON ccu.constraint_name = rc.constraint_name
459+ AND ccu.constraint_schema = rc.constraint_schema
460+ WHERE tc.table_name = '%s'
461+ )
462+ SELECT
463+ ROW_NUMBER() OVER () - 1 AS id,
464+ seq,
465+ table_name AS parent_table,
466+ "from",
467+ "to",
468+ on_update,
469+ on_delete,
470+ 'NONE' AS match
471+ FROM foreign_keys;` , table )
472472 res_fk , _ , err := db .QueryMultiRows (_query , []interface {}{}... )
473473 if err != nil {
474474 return nil , false , err
@@ -481,7 +481,7 @@ FROM foreign_keys;`, table)
481481 }
482482 }
483483 for _ , row := range * res {
484- fmt .Println ("NAME:" , row ["name" ])
484+ // fmt.Println("NAME:", row["name"])
485485 fk := false
486486 var referred_table string
487487 var referred_column string
@@ -730,7 +730,7 @@ func (db *DB) GetUserByNameOrEmail(email string) (map[string]any, bool, error) {
730730 user := map [string ]any {}
731731
732732 query := `SELECT * FROM users WHERE email = $1 OR username = $1`
733- fmt .Println (email )
733+ // fmt.Println(email)
734734 //err := db.GetContext(ctx, &user2, query, email)
735735 rows , err := db .QueryxContext (ctx , query , email )
736736 if err != nil {
@@ -857,7 +857,7 @@ func (db *DB) Query2CSV(query string, csv_path string, params ...interface{}) (b
857857 // Format large numbers without scientific notation
858858 hasDec , err := hasDecimalPlace (v )
859859 if err != nil {
860- fmt .Println (err )
860+ // fmt.Println(err)
861861 rowData = append (rowData , fmt .Sprintf ("%v" , value ))
862862 } else if hasDec {
863863 rowData = append (rowData , fmt .Sprintf ("%f" , v ))
0 commit comments