stvnnnnnn commited on
Commit
93661e2
·
verified ·
1 Parent(s): f3ff324

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -222,6 +222,9 @@ class PostgresManager:
222
  in_dollar = False # estamos dentro de $$...$$ ?
223
  dollar_tag = "" # por ej. "$func$"
224
 
 
 
 
225
  def flush_statement():
226
  nonlocal buffer
227
  stmt = buffer.strip()
@@ -245,11 +248,28 @@ class PostgresManager:
245
  line = raw_line.rstrip("\n")
246
  stripped = line.strip()
247
 
248
- # Comentarios y líneas vacías (fuera de COPY)
249
- if not in_copy:
 
 
 
 
 
 
 
250
  if not stripped or stripped.startswith("--"):
251
  continue
252
 
 
 
 
 
 
 
 
 
 
 
253
  # ====== BLOQUE COPY ... FROM stdin ======
254
  if in_copy:
255
  if stripped == r"\.":
 
222
  in_dollar = False # estamos dentro de $$...$$ ?
223
  dollar_tag = "" # por ej. "$func$"
224
 
225
+ in_domain_block = False # 👈 estamos dentro de un bloque CREATE DOMAIN ?
226
+ in_function_block = False # 👈 estamos dentro de un CREATE FUNCTION ?
227
+
228
  def flush_statement():
229
  nonlocal buffer
230
  stmt = buffer.strip()
 
248
  line = raw_line.rstrip("\n")
249
  stripped = line.strip()
250
 
251
+ # ====== BLOQUE CREATE FUNCTION (lo ignoramos entero) ======
252
+ if in_function_block:
253
+ # Cerramos cuando vemos algo tipo "$_$;" o "$func$;"
254
+ if re.search(r"\$[A-Za-z0-9_]*\$;", stripped):
255
+ in_function_block = False
256
+ continue
257
+
258
+ # Comentarios y líneas vacías (fuera de COPY / DOMAIN / FUNCTION)
259
+ if not in_copy and not in_domain_block:
260
  if not stripped or stripped.startswith("--"):
261
  continue
262
 
263
+ upper_line = stripped.upper()
264
+ if (
265
+ upper_line.startswith("CREATE FUNCTION")
266
+ or upper_line.startswith("CREATE OR REPLACE FUNCTION")
267
+ or upper_line.startswith("ALTER FUNCTION")
268
+ ):
269
+ # Ignoramos toda la función (cabecera + cuerpo)
270
+ in_function_block = True
271
+ continue
272
+
273
  # ====== BLOQUE COPY ... FROM stdin ======
274
  if in_copy:
275
  if stripped == r"\.":