Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Compiled Cypher on Postgres: apply =~'s two pattern rewrites in drivine4j's order

Aperta Adatta ai principianti
#250 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
postgresql, python
Ambito
database

Direzione di ricerca

Inizia da drivine/cypher/sql/postgres_cypher_compiler.py:589, in matches, e confronta le due chiamate a regexp_replace con l’ordine mostrato nell’issue. Scambia il loro ordine in modo che l’ancoraggio avvenga per primo. Controlla l’SQL compilato per il pattern di esempio e conferma che le istruzioni della spec producano lo stesso testo delle altre librerie Drivine.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A tidy-up. The results are the same; only the SQL text differs from drivine4j's.

I compiled the 998 statements of the Cypher spec at v0.6.18 with drivine4j (main, 3c5c4e5a), Drivine for TypeScript (master, e5b5d2b) and this library (main, a684245). On Postgres, =~ is the one place where this library alone writes different text from the other two.

What happens: matches (drivine/cypher/sql/postgres_cypher_compiler.py:589) first adds the w flag, when the flags hold both s and m, and then anchors the pattern:

regexp_replace(regexp_replace(<pattern>, '^\(\?([a-z]*(s[a-z]*m|m[a-z]*s)[a-z]*)\)', '(?\1w)'), '^(\(\?([a-z]+)\))?(.*)$', '(?p\2)\\A(\3)\\Z')

drivine4j (PostgresCypherCompiler.kt:416) and Drivine for TypeScript (PostgresCypherCompiler.ts:503) anchor first and then add the w:

regexp_replace(regexp_replace(<pattern>, '^(\(\?([a-z]+)\))?(.*)$', '(?p\2)\\A(\3)\\Z'), '^\(\?([a-z]*(s[a-z]*m|m[a-z]*s)[a-z]*)\)', '(?\1w)')

Both orders turn (?sm)a.b into (?psmw)\A(a.b)\Z. A pattern without both flags gets no w either way. So the results are the same, and the spec passes here. This shows up in 11 spec statements, for example RETURN 'a\nb' =~ '(?ims)A$.^B'.

Why bother: with the same text, a compile of the spec compares byte for byte across the libraries, so a real difference stands out. These 11 are about a quarter of the 41 Postgres statements where the two ports' SQL differs.

A fix: swap the two regexp_replace calls in matches, so the pattern is anchored first, as drivine4j does.

A tidy-up, so it goes in Next release + 2.

Lingua principale
Python
Stelle
1
Fork
0
Merge medio
1h 19m
PR unite (30g)
122

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di liberation-data/drivine-python

Tutte le issue di liberation-data/drivine-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.