MCPcopy Create free account
hub / github.com/ElementsProject/lightning / rewrite_single

Method rewrite_single

devtools/sql-rewrite.py:63–85  ·  view source on GitHub ↗
(self, q)

Source from the content-addressed store, hash-verified

61
62class PostgresRewriter(Rewriter):
63 def rewrite_single(self, q):
64 # Replace DB specific queries with a no-op
65 if "/*SQLITE*/" in q:
66 return "UPDATE vars SET intval=1 WHERE name='doesnotexist'" # Return a no-op
67
68 # Let's start by replacing any eventual '?' placeholders
69 q2 = ""
70 count = 1
71 for c in q:
72 if c == '?':
73 c = "${}".format(count)
74 count += 1
75 q2 += c
76 query = q2
77
78 typemapping = {
79 r'BLOB': 'BYTEA',
80 r'_ROWID_': '(((ctid::text::point)[0]::bigint << 32) | (ctid::text::point)[1]::bigint)', # Yeah, I know...
81 r'CURRENT_TIMESTAMP\(\)': "EXTRACT(epoch FROM now())",
82 }
83
84 query = self.rewrite_types(query, typemapping)
85 return query
86
87
88rewriters = {

Callers

nothing calls this directly

Calls 1

rewrite_typesMethod · 0.80

Tested by

no test coverage detected