stvnnnnnn commited on
Commit
4847f96
·
verified ·
1 Parent(s): b9785dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -31
app.py CHANGED
@@ -212,7 +212,7 @@ class PostgresManager:
212
  - Reescribe public./pagila. -> schema_name.
213
  - Respeta funciones con $$...$$ (no corta por ';' internos).
214
  - Ignora statements peligrosos via _should_skip_statement().
215
- - Ignora bloques CREATE DOMAIN ... multi-línea sin usar regex agresivos.
216
  """
217
 
218
  in_copy = False
@@ -223,7 +223,7 @@ class PostgresManager:
223
  in_dollar = False # estamos dentro de $$...$$ ?
224
  dollar_tag = "" # por ej. "$func$"
225
 
226
- in_domain_block = False # 👈 estamos dentro de un bloque CREATE DOMAIN ?
227
 
228
  def flush_statement():
229
  nonlocal buffer
@@ -275,40 +275,23 @@ class PostgresManager:
275
 
276
  # Detectar inicio de bloque DOMAIN
277
  if stripped.upper().startswith("CREATE DOMAIN"):
278
- # Entramos en bloque DOMAIN y lo ignoramos hasta el ';'
279
  in_domain_block = True
280
  continue
281
 
282
- # Detectar inicio de COPY
283
- if (
284
- # Primero reescribimos la línea según el schema
285
- line = self._rewrite_line_for_schema(line, schema_name)
286
- stripped = line.strip()
287
-
288
- # SOLO después detectamos COPY
289
- if stripped.upper().startswith("COPY ") and "FROM stdin" in stripped.upper():
290
- flush_statement()
291
- in_copy = True
292
- copy_sql = stripped
293
- copy_lines = []
294
- continue
295
- ):
296
- # Ejecutar lo que haya pendiente antes del COPY
297
  flush_statement()
298
  in_copy = True
299
- # Reescribimos también el encabezado COPY
300
- copy_sql = (
301
- self._rewrite_line_for_schema(stripped, schema_name)
302
- .strip()
303
- )
304
  copy_lines = []
305
  continue
306
 
307
- # Reescribir la línea según el schema de sesión
308
- line = self._rewrite_line_for_schema(line, schema_name)
309
- if not line.strip():
310
- continue
311
-
312
  # Escanear la línea caracter a caracter para detectar $tag$ y ';'
313
  i = 0
314
  start_seg = 0
@@ -321,9 +304,7 @@ class PostgresManager:
321
  if ch == "$":
322
  # ¿Inicio o fin de bloque dollar-quoted?
323
  j = i + 1
324
- while j < length and (
325
- line[j].isalnum() or line[j] == "_"
326
- ):
327
  j += 1
328
  if j < length and line[j] == "$":
329
  tag = line[i : j + 1] # incluye ambos '$'
 
212
  - Reescribe public./pagila. -> schema_name.
213
  - Respeta funciones con $$...$$ (no corta por ';' internos).
214
  - Ignora statements peligrosos via _should_skip_statement().
215
+ - Ignora bloques CREATE DOMAIN ... multi-línea.
216
  """
217
 
218
  in_copy = False
 
223
  in_dollar = False # estamos dentro de $$...$$ ?
224
  dollar_tag = "" # por ej. "$func$"
225
 
226
+ in_domain_block = False # estamos dentro de un bloque CREATE DOMAIN ?
227
 
228
  def flush_statement():
229
  nonlocal buffer
 
275
 
276
  # Detectar inicio de bloque DOMAIN
277
  if stripped.upper().startswith("CREATE DOMAIN"):
 
278
  in_domain_block = True
279
  continue
280
 
281
+ # 👉 Primero reescribimos la línea según el schema de sesión
282
+ line = self._rewrite_line_for_schema(line, schema_name)
283
+ if not line.strip():
284
+ continue
285
+ stripped = line.strip()
286
+
287
+ # Detectar inicio de COPY (YA con la línea reescrita)
288
+ if stripped.upper().startswith("COPY ") and "FROM stdin" in stripped.upper():
 
 
 
 
 
 
 
289
  flush_statement()
290
  in_copy = True
291
+ copy_sql = stripped
 
 
 
 
292
  copy_lines = []
293
  continue
294
 
 
 
 
 
 
295
  # Escanear la línea caracter a caracter para detectar $tag$ y ';'
296
  i = 0
297
  start_seg = 0
 
304
  if ch == "$":
305
  # ¿Inicio o fin de bloque dollar-quoted?
306
  j = i + 1
307
+ while j < length and (line[j].isalnum() or line[j] == "_"):
 
 
308
  j += 1
309
  if j < length and line[j] == "$":
310
  tag = line[i : j + 1] # incluye ambos '$'