@@ -475,6 +475,94 @@ func TestGenerateSelect(t *testing.T) {
475475 },
476476 wantErr : false ,
477477 },
478+ {
479+ name : "condition_with_boolean_true" ,
480+ args : args {
481+ tableName : "users" ,
482+ fieldNames : []string {"id" , "name" , "is_active" },
483+ index : postgres.Index {
484+ Unique : false ,
485+ Fields : postgres.OrderedFields {postgres.OrderField {Field : "id" , Order : postgres .ASC }},
486+ Condition : []postgres.Condition {{Field : "is_active" , Operator : "=" , Values : []any {true }}},
487+ },
488+ keys : [][]any {{1 }},
489+ offset : 0 ,
490+ limit : 0 ,
491+ cursor : postgres.CursorPosition {},
492+ },
493+ want : & postgres.Query {
494+ QueryString : `SELECT id, name, is_active FROM "users" WHERE is_active = $1 AND id = $2 ORDER BY id ASC` ,
495+ ConditionExists : true ,
496+ Params : []any {true , 1 },
497+ },
498+ wantErr : false ,
499+ },
500+ {
501+ name : "condition_with_boolean_false" ,
502+ args : args {
503+ tableName : "users" ,
504+ fieldNames : []string {"id" , "name" , "is_deleted" },
505+ index : postgres.Index {
506+ Unique : false ,
507+ Fields : postgres.OrderedFields {postgres.OrderField {Field : "id" , Order : postgres .ASC }},
508+ Condition : []postgres.Condition {{Field : "is_deleted" , Operator : "=" , Values : []any {false }}},
509+ },
510+ keys : [][]any {{2 }},
511+ offset : 0 ,
512+ limit : 0 ,
513+ cursor : postgres.CursorPosition {},
514+ },
515+ want : & postgres.Query {
516+ QueryString : `SELECT id, name, is_deleted FROM "users" WHERE is_deleted = $1 AND id = $2 ORDER BY id ASC` ,
517+ ConditionExists : true ,
518+ Params : []any {false , 2 },
519+ },
520+ wantErr : false ,
521+ },
522+ {
523+ name : "condition_with_boolean_not_equal" ,
524+ args : args {
525+ tableName : "users" ,
526+ fieldNames : []string {"id" , "name" , "is_verified" },
527+ index : postgres.Index {
528+ Unique : false ,
529+ Fields : postgres.OrderedFields {postgres.OrderField {Field : "id" , Order : postgres .ASC }},
530+ Condition : []postgres.Condition {{Field : "is_verified" , Operator : "!=" , Values : []any {false }}},
531+ },
532+ keys : [][]any {{3 }},
533+ offset : 0 ,
534+ limit : 0 ,
535+ cursor : postgres.CursorPosition {},
536+ },
537+ want : & postgres.Query {
538+ QueryString : `SELECT id, name, is_verified FROM "users" WHERE is_verified != $1 AND id = $2 ORDER BY id ASC` ,
539+ ConditionExists : true ,
540+ Params : []any {false , 3 },
541+ },
542+ wantErr : false ,
543+ },
544+ {
545+ name : "bulk_query_with_boolean_condition" ,
546+ args : args {
547+ tableName : "users" ,
548+ fieldNames : []string {"id" , "name" , "is_active" },
549+ index : postgres.Index {
550+ Unique : false ,
551+ Fields : postgres.OrderedFields {postgres.OrderField {Field : "id" , Order : postgres .ASC }},
552+ Condition : []postgres.Condition {{Field : "is_active" , Operator : "=" , Values : []any {true }}},
553+ },
554+ keys : [][]any {{1 }, {2 }, {3 }},
555+ offset : 0 ,
556+ limit : 10 ,
557+ cursor : postgres.CursorPosition {},
558+ },
559+ want : & postgres.Query {
560+ QueryString : `SELECT id, name, is_active FROM "users" WHERE is_active = $1 AND id IN ($2, $3, $4) ORDER BY id ASC LIMIT 10` ,
561+ ConditionExists : true ,
562+ Params : []any {true , 1 , 2 , 3 },
563+ },
564+ wantErr : false ,
565+ },
478566 }
479567
480568 for _ , tt := range tests {
0 commit comments