@@ -30,8 +30,13 @@ private function getInputParams()
3030
3131 private function condTest ($ sql ,$ equal )
3232 {
33+ $ equal =$ equal .' FORMAT JSON ' ;
3334 $ input_params =$ this ->getInputParams ();
35+ // echo "-----\n".$this->client->selectAsync($sql, $input_params)->sql()."\n----\n";
36+
3437 $ this ->assertEquals ($ equal ,$ this ->client ->selectAsync ($ sql , $ input_params )->sql ());
38+
39+
3540 }
3641 /**
3742 *
@@ -106,32 +111,34 @@ public function testSqlConditionsBig()
106111 $ this ->restartClickHouseClient ();
107112 $ this ->client ->enableQueryConditions ();
108113 $ input_params =$ this ->getInputParams ();
114+
115+
109116 $ this ->assertNotContains (
110117 'NOT_SHOW ' ,$ this ->client ->selectAsync ($ select , $ input_params )->sql ()
111118 );
112119
113-
114120 }
115121 public function testSqlConditions1 ()
116122 {
117123 $ this ->restartClickHouseClient ();
118124 $ this ->client ->enableQueryConditions ();
119125
120- $ this ->condTest ('{ifint s_empty}NOT_SHOW{/if}{ifbool int1}NOT_SHOW{else}OK{/if}{ifbool int30}NOT_SHOW{else}OK{/if} ' ,'OKOK FORMAT JSON ' );
121- $ this ->condTest ('{ifbool false}OK{/if}{ifbool true}OK{/if}{ifbool true}OK{else}NOT_SHOW{/if} ' ,'OKOK FORMAT JSON ' );
122- $ this ->condTest ('{ifstring s_empty}NOT_SHOW{else}OK{/if}{ifstring s_null}OK{else}NOT_SHOW{/if} ' ,'OKOK FORMAT JSON ' );
123- $ this ->condTest ('{ifint int1} OK {/if} ' ,' OK FORMAT JSON ' );
124- $ this ->condTest ('{ifint s_empty}NOT_SHOW{/if}_1_ ' ,'_1_ FORMAT JSON ' );
125- $ this ->condTest ('1_{ifint str0} NOT_SHOW {else}OK{/if}_2 ' ,'1_OK_2 FORMAT JSON ' );
126- $ this ->condTest ('1_{if zero}OK{/if}_2 ' ,'1_OK_2 FORMAT JSON ' );
127- $ this ->condTest ('1_{if empty}OK{/if}_2 ' ,'1__2 FORMAT JSON ' );
128- $ this ->condTest ('1_{if s_false}OK{/if}_2 ' ,'1_OK_2 FORMAT JSON ' );
129- $ this ->condTest ('1_{if qwert}NOT_SHOW{/if}_2 ' ,'1__2 FORMAT JSON ' );
130- $ this ->condTest ('1_{ifset zero} NOT_SHOW {else}OK{/if}{ifset false} NOT_SHOW {/if}{ifset s_false} OK {/if}_2 ' ,'1_OK OK_2 FORMAT JSON ' );
131- $ this ->condTest ('1_{ifint zero} NOT_SHOW {/if}{if zero}OK{/if}{ifint s_empty}NOT_SHOW{/if}_2 ' ,'1_OK_2 FORMAT JSON ' );
132- $ this ->condTest ('1_{ifint s_null}NOT_SHOW{/if}{ifset null} NOT_SHOW {/if}_2 ' ,'1__2 FORMAT JSON ' );
133-
134-
126+ $ this ->condTest ('{ifint s_empty}NOT_SHOW{/if}{ifbool int1}NOT_SHOW{else}OK{/if}{ifbool int30}NOT_SHOW{else}OK{/if} ' ,'OKOK ' );
127+ $ this ->condTest ('{ifbool false}OK{/if}{ifbool true}OK{/if}{ifbool true}OK{else}NOT_SHOW{/if} ' ,'OKOK ' );
128+ $ this ->condTest ('{ifstring s_empty}NOT_SHOW{else}OK{/if}{ifstring s_null}OK{else}NOT_SHOW{/if} ' ,'OKOK ' );
129+ $ this ->condTest ('{ifint int1} OK {/if} ' ,' OK ' );
130+ $ this ->condTest ('{ifint s_empty}NOT_SHOW{/if}_1_ ' ,'_1_ ' );
131+ $ this ->condTest ('1_{ifint str0} NOT_SHOW {else}OK{/if}_2 ' ,'1_OK_2 ' );
132+ $ this ->condTest ('1_{if zero}OK{/if}_2 ' ,'1_OK_2 ' );
133+ $ this ->condTest ('1_{if empty}OK{/if}_2 ' ,'1__2 ' );
134+ $ this ->condTest ('1_{if s_false}OK{/if}_2 ' ,'1_OK_2 ' );
135+ $ this ->condTest ('1_{if qwert}NOT_SHOW{/if}_2 ' ,'1__2 ' );
136+ $ this ->condTest ('1_{ifset zero} NOT_SHOW {else}OK{/if}{ifset false} NOT_SHOW {/if}{ifset s_false} OK {/if}_2 ' ,'1_OK OK_2 ' );
137+ $ this ->condTest ('1_{ifint zero} NOT_SHOW {/if}{if zero}OK{/if}{ifint s_empty}NOT_SHOW{/if}_2 ' ,'1_OK_2 ' );
138+ $ this ->condTest ('1_{ifint s_null}NOT_SHOW{/if}{ifset null} NOT_SHOW {/if}_2 ' ,'1__2 ' );
139+ $ this ->condTest ("{ifint lastdays} \n\n\nevent_date>=today()-{lastdays}-{lastdays}-{lastdays} \n\n\n{else} \n\n\nevent_date>=today() \n\n\n{/if} " , "\n\n\nevent_date>=today()-3-3-3 \n\n\n" );
140+ $ this ->condTest ("1_{ifint lastdays} \n2_{lastdays}_ \t{int1}_{str0}_{str1} \n_6{else} \n\n{/if} " , "1_ \n2_3_ \t1_0_1 \n_6 " );
141+ $ this ->condTest ("1_{ifint qwer} \n\n\n\n_6{else} \n{int1}{str0}{str1} \n{/if} \n_77 " , "1_ \n101 \n_77 " );
135142
136143
137144 }
0 commit comments