File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -311,11 +311,22 @@ def handle_node(node):
311311 current_limit = parsed_query .args .get ("limit" )
312312 logging .debug ("Current Limit: %s" , current_limit )
313313
314- if current_limit is None or current_limit .value > self .row_limit :
314+ # More defensive check to handle different structures
315+ should_add_limit = True
316+ if current_limit is not None :
317+ try :
318+ if hasattr (current_limit , "expression" ) and hasattr (
319+ current_limit .expression , "value"
320+ ):
321+ if current_limit .expression .value <= self .row_limit :
322+ should_add_limit = False
323+ except AttributeError :
324+ logging .warning ("Unexpected limit structure: %s" , current_limit )
325+
326+ if should_add_limit :
315327 # Create a new LIMIT expression
316328 limit_expr = Limit (expression = Literal .number (self .row_limit ))
317-
318- # Attach it to the query by setting it on the SELECT expression
329+ # Attach it to the query
319330 parsed_query .set ("limit" , limit_expr )
320331 updated_parsed_queries .append (
321332 parsed_query .sql (dialect = self .database_engine .value .lower ())
You can’t perform that action at this time.
0 commit comments