@@ -176,7 +176,7 @@ public static function new_slave_connection( $command, $cwd = null, $env = null
176176 return new gpMediaWikiGlue ( new gpSlaveTransport ($ command , $ cwd , $ env ) );
177177 }
178178
179- public function condition_sql ( $ where , $ assume_literals = true ) {
179+ public function condition_sql ( $ where , $ assume_literals = true , $ inverse = false ) {
180180 if ( is_array ($ where ) ) {
181181 if ( isset ( $ where [0 ] ) ) { #indexed array
182182 $ where = '( ' . implode (') AND ( ' , $ where ) . ') ' ;
@@ -188,9 +188,9 @@ public function condition_sql( $where, $assume_literals = true ) {
188188 $ where .= '( ' ;
189189 $ where .= $ k ;
190190
191- if ( is_array ($ v ) ) $ where .= ( $ inverse ? " not in " : " in " ) . $ this ->glue -> as_list ( $ v );
191+ if ( is_array ($ v ) ) $ where .= ( $ inverse ? " not in " : " in " ) . $ this ->as_list ( $ v );
192192 elseif ( is_string ($ v ) && !$ assume_literals ) $ where .= ( $ inverse ? " != " : " = " ) . $ v ; # field reference or quoted literal
193- else $ where .= ( $ inverse ? " != " : " = " ) . $ this ->glue -> as_literal ( $ v );
193+ else $ where .= ( $ inverse ? " != " : " = " ) . $ this ->as_literal ( $ v );
194194
195195 $ where .= ') ' ;
196196 }
@@ -240,26 +240,13 @@ public function get_table() {
240240 }
241241
242242 public function create_table ( ) {
243- $ table = $ this ->table ;
244- $ t = "" ;
245-
246- if ( !$ table || $ table === '? ' ) {
247- $ table = "gp_temp_ " . $ this ->glue ->next_id ();
248- $ t = " TEMPORARY " ;
249- }
250-
251- $ sql = "CREATE $ t TABLE " . $ table ;
252- $ sql .= "( " ;
253- $ sql .= $ this ->table_obj ->get_field_definitions ();
254- $ sql .= ") " ;
255-
256- $ this ->query ($ sql );
257-
258- $ this ->table = $ table ;
259- $ this ->table_obj ->set_name ( $ this ->table );
260- $ this ->table_id_obj ->set_name ( $ this ->table );
243+ #TODO: port this solution using make_temp_table to python!
244+ $ this ->table_obj = $ this ->glue ->make_temp_table ( $ this ->table_obj );
261245
262- return $ table ;
246+ $ this ->table = $ this ->table_obj ->get_name ();
247+ $ this ->table_id_obj ->set_name ( $ this ->table );
248+
249+ return $ this ->table ;
263250
264251 }
265252
@@ -447,7 +434,7 @@ public function remove_page_id( $id ) {
447434 }
448435
449436 public function strip_namespace ( $ ns , $ inverse = false ) {
450- $ where = $ this ->namespace_field . ' = ' . ( int ) $ ns ;
437+ $ where = array ( $ this ->namespace_field => $ ns ) ;
451438 return $ this ->strip ( $ where , null , $ inverse );
452439 }
453440
@@ -502,7 +489,7 @@ public function retian_larger( $size ) { #TODO: port to python!
502489 }
503490
504491 public function strip ( $ where , $ join = null , $ inverse = false ) { #TODO: port to python!
505- if ( $ where ) $ where = $ this ->glue ->condition_sql ($ where );
492+ if ( $ where ) $ where = $ this ->glue ->condition_sql ($ where, true , $ inverse );
506493
507494 if ( is_array ($ join ) ) {
508495 if ( isset ( $ join [0 ] ) ) { #indexed array
@@ -521,8 +508,8 @@ public function strip( $where, $join = null, $inverse = false ) { #TODO: port to
521508 }
522509
523510 if ( $ join ) {
524- $ sql = 'DELETE FROM TTT ' ;
525- $ sql .= ' USING ' . $ this ->table . ' AS TTT ' ;
511+ $ sql = 'DELETE FROM T ' ;
512+ $ sql .= ' USING ' . $ this ->table . ' AS T ' ;
526513 $ sql .= $ join ;
527514 } else {
528515 $ sql = 'DELETE FROM ' . $ this ->table ;
0 commit comments