sqlui 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/app/environment.rb +4 -1
- data/app/server.rb +22 -18
- data/app/sqlui.rb +36 -37
- data/bin/sqlui +1 -0
- data/client/resources/sqlui.js +121 -114
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db5b12190e0cde95f8a0063703cf3e0398bd8cfa862f1122b90c4f95b721c1ce
|
4
|
+
data.tar.gz: 0b9a4db845a28a5a40923e8107bf961472cf57928b197b2b610b4e957fd365aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e74d51eccdec8b53c8e9455f555a55ab2cde80ae3e800b11efbbc57eb8f86bdcb8528faa2b70bc3589c2205baa3f3a7a08d866548257d045de89a437199c75b
|
7
|
+
data.tar.gz: 87b4226337f573e294e2f181dc9c0485bc1ab407f0585d6c3c7232c5d965f6d7315cd138656a40337169ce39a01c2f18ad16f2855f5e506db8ac0eb4222a70f0
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.17
|
data/app/environment.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Parses and provides access to environment variables.
|
1
4
|
class Environment
|
2
5
|
SERVER_ENV = ENV.fetch('SERVER_ENV', 'development').to_sym
|
3
6
|
SERVER_PORT = ENV.fetch('SERVER_PORT', 8080)
|
@@ -17,4 +20,4 @@ class Environment
|
|
17
20
|
def self.server_port
|
18
21
|
SERVER_PORT
|
19
22
|
end
|
20
|
-
end
|
23
|
+
end
|
data/app/server.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'erb'
|
2
4
|
require 'json'
|
3
5
|
require 'mysql2'
|
@@ -12,14 +14,16 @@ if ARGV.include?('-v') || ARGV.include?('--version')
|
|
12
14
|
end
|
13
15
|
|
14
16
|
raise 'you must specify a configuration file' unless ARGV.size == 1
|
15
|
-
raise
|
17
|
+
raise 'configuration file does not exist' unless File.exist?(ARGV[0])
|
16
18
|
|
19
|
+
# SQLUI Sinatra server.
|
17
20
|
class Server < Sinatra::Base
|
18
21
|
set :logging, true
|
19
22
|
set :bind, '0.0.0.0'
|
20
23
|
set :port, Environment.server_port
|
21
24
|
set :env, Environment.server_env
|
22
25
|
|
26
|
+
# A MySQL client. This needs to go away.
|
23
27
|
class Client
|
24
28
|
def initialize(params)
|
25
29
|
@params = params
|
@@ -35,30 +39,30 @@ class Server < Sinatra::Base
|
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
|
-
config = YAML.
|
42
|
+
config = YAML.safe_load(ERB.new(File.read(ARGV[0])).result)
|
39
43
|
saved_path_root = config['saved_path']
|
40
|
-
client_map = config['databases'].values.
|
44
|
+
client_map = config['databases'].values.to_h do |database_config|
|
41
45
|
client_params = {
|
42
|
-
host:
|
43
|
-
port:
|
44
|
-
username:
|
45
|
-
password:
|
46
|
-
database:
|
47
|
-
read_timeout:
|
48
|
-
write_timeout:
|
46
|
+
host: database_config['db_host'],
|
47
|
+
port: database_config['db_port'] || 3306,
|
48
|
+
username: database_config['db_username'],
|
49
|
+
password: database_config['db_password'],
|
50
|
+
database: database_config['db_database'],
|
51
|
+
read_timeout: 10, # seconds
|
52
|
+
write_timeout: 0, # seconds
|
49
53
|
connect_timeout: 5 # seconds
|
50
54
|
}
|
51
55
|
client = Client.new(client_params)
|
52
56
|
[
|
53
|
-
database_config['url_path'],
|
57
|
+
database_config['url_path'],
|
54
58
|
::SQLUI.new(
|
55
|
-
client:
|
59
|
+
client: client,
|
56
60
|
table_schema: database_config['db_database'],
|
57
|
-
name:
|
58
|
-
saved_path:
|
61
|
+
name: database_config['name'],
|
62
|
+
saved_path: File.join(saved_path_root, database_config['saved_path'])
|
59
63
|
)
|
60
64
|
]
|
61
|
-
end
|
65
|
+
end
|
62
66
|
|
63
67
|
get '/-/health' do
|
64
68
|
status 200
|
@@ -66,7 +70,7 @@ class Server < Sinatra::Base
|
|
66
70
|
end
|
67
71
|
|
68
72
|
get '/db/?' do
|
69
|
-
erb :databases, :
|
73
|
+
erb :databases, locals: { databases: config['databases'] }
|
70
74
|
end
|
71
75
|
|
72
76
|
get '/db/:database' do
|
@@ -76,7 +80,7 @@ class Server < Sinatra::Base
|
|
76
80
|
get '/db/:database/:route' do
|
77
81
|
response = client_map[params[:database]].get(params)
|
78
82
|
status response[:status]
|
79
|
-
headers
|
83
|
+
headers 'Content-Type': response[:content_type]
|
80
84
|
body response[:body]
|
81
85
|
end
|
82
86
|
|
@@ -84,7 +88,7 @@ class Server < Sinatra::Base
|
|
84
88
|
post_body = JSON.parse(request.body.read)
|
85
89
|
response = client_map[params[:database]].post(params.merge(post_body))
|
86
90
|
status response[:status]
|
87
|
-
headers
|
91
|
+
headers 'Content-Type': response[:content_type]
|
88
92
|
body response[:body]
|
89
93
|
end
|
90
94
|
|
data/app/sqlui.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'uri'
|
3
5
|
require 'set'
|
4
6
|
|
7
|
+
# Main SQLUI class responsible for producing web content. This class needs to die.
|
5
8
|
class SQLUI
|
6
9
|
MAX_ROWS = 1_000
|
7
10
|
|
8
|
-
def initialize(client:, table_schema: nil,
|
11
|
+
def initialize(client:, name:, saved_path:, table_schema: nil, max_rows: MAX_ROWS)
|
9
12
|
@client = client
|
10
13
|
@table_schema = table_schema
|
11
14
|
@name = name
|
@@ -65,12 +68,10 @@ class SQLUI
|
|
65
68
|
end
|
66
69
|
|
67
70
|
def query_file(params)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
raise 'missing file param'
|
73
|
-
end
|
71
|
+
raise 'missing file param' unless params['file']
|
72
|
+
|
73
|
+
sql = File.read("#{@saved_path}/#{params['file']}")
|
74
|
+
execute_query(sql).tap { |r| r[:file] = params[:file] }
|
74
75
|
end
|
75
76
|
|
76
77
|
def metadata
|
@@ -79,21 +80,21 @@ class SQLUI
|
|
79
80
|
|
80
81
|
def load_metadata
|
81
82
|
result = {
|
82
|
-
server:
|
83
|
+
server: @name,
|
83
84
|
schemas: {},
|
84
|
-
saved:
|
85
|
+
saved: Dir.glob("#{@saved_path}/*.sql").map do |path|
|
85
86
|
{
|
86
|
-
filename:
|
87
|
+
filename: File.basename(path),
|
87
88
|
description: File.readlines(path).take_while { |l| l.start_with?('--') }.map { |l| l.sub(/^-- */, '') }.join
|
88
89
|
}
|
89
90
|
end
|
90
91
|
}
|
91
92
|
|
92
|
-
if @table_schema
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
93
|
+
where_clause = if @table_schema
|
94
|
+
"where table_schema = '#{@table_schema}'"
|
95
|
+
else
|
96
|
+
"where table_schema not in('mysql', 'sys', 'information_schema', 'performance_schema')"
|
97
|
+
end
|
97
98
|
column_result = @client.query(
|
98
99
|
<<~SQL
|
99
100
|
select
|
@@ -129,9 +130,7 @@ class SQLUI
|
|
129
130
|
end
|
130
131
|
columns = result[:schemas][table_schema][:tables][table_name][:columns]
|
131
132
|
column_name = row[:column_name]
|
132
|
-
unless columns[column_name]
|
133
|
-
columns[column_name] = {}
|
134
|
-
end
|
133
|
+
columns[column_name] = {} unless columns[column_name]
|
135
134
|
column = columns[column_name]
|
136
135
|
column[:name] = column_name
|
137
136
|
column[:data_type] = row[:data_type]
|
@@ -142,11 +141,11 @@ class SQLUI
|
|
142
141
|
column[:extra] = row[:extra]
|
143
142
|
end
|
144
143
|
|
145
|
-
if @table_schema
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
144
|
+
where_clause = if @table_schema
|
145
|
+
"where table_schema = '#{@table_schema}'"
|
146
|
+
else
|
147
|
+
"where table_schema not in('mysql', 'sys', 'information_schema', 'performance_schema')"
|
148
|
+
end
|
150
149
|
stats_result = @client.query(
|
151
150
|
<<~SQL
|
152
151
|
select
|
@@ -168,9 +167,7 @@ class SQLUI
|
|
168
167
|
table_name = row[:table_name]
|
169
168
|
indexes = tables[table_name][:indexes]
|
170
169
|
index_name = row[:index_name]
|
171
|
-
unless indexes[index_name]
|
172
|
-
indexes[index_name] = {}
|
173
|
-
end
|
170
|
+
indexes[index_name] = {} unless indexes[index_name]
|
174
171
|
index = indexes[index_name]
|
175
172
|
column_name = row[:column_name]
|
176
173
|
index[column_name] = {}
|
@@ -186,13 +183,13 @@ class SQLUI
|
|
186
183
|
|
187
184
|
def execute_query(sql)
|
188
185
|
result = @client.query(sql)
|
189
|
-
rows = result.map
|
186
|
+
rows = result.map(&:values)
|
190
187
|
columns = result.first&.keys || []
|
191
188
|
column_types = columns.map { |_| 'string' }
|
192
189
|
unless rows.empty?
|
193
190
|
maybe_non_null_column_value_exemplars = columns.each_with_index.map do |_, index|
|
194
|
-
row = rows.find do |
|
195
|
-
!
|
191
|
+
row = rows.find do |current|
|
192
|
+
!current[index].nil?
|
196
193
|
end
|
197
194
|
row.nil? ? nil : row[index]
|
198
195
|
end
|
@@ -210,22 +207,24 @@ class SQLUI
|
|
210
207
|
end
|
211
208
|
end
|
212
209
|
{
|
213
|
-
query:
|
214
|
-
columns:
|
210
|
+
query: sql,
|
211
|
+
columns: columns,
|
215
212
|
column_types: column_types,
|
216
|
-
total_rows:
|
217
|
-
rows:
|
213
|
+
total_rows: rows.size,
|
214
|
+
rows: rows.take(@max_rows)
|
218
215
|
}
|
219
216
|
end
|
220
217
|
|
221
218
|
def find_query_at_cursor(sql, cursor)
|
222
219
|
parts_with_ranges = []
|
223
220
|
sql.scan(/[^;]*;[ \n]*/) { |part| parts_with_ranges << [part, 0, part.size] }
|
224
|
-
parts_with_ranges.inject(0) do |pos,
|
225
|
-
|
226
|
-
|
221
|
+
parts_with_ranges.inject(0) do |pos, current|
|
222
|
+
current[1] += pos
|
223
|
+
current[2] += pos
|
227
224
|
end
|
228
|
-
part_with_range = parts_with_ranges.find
|
225
|
+
part_with_range = parts_with_ranges.find do |current|
|
226
|
+
cursor >= current[1] && cursor < current[2]
|
227
|
+
end || parts_with_ranges[-1]
|
229
228
|
part_with_range[0]
|
230
229
|
end
|
231
230
|
end
|
data/bin/sqlui
CHANGED
data/client/resources/sqlui.js
CHANGED
@@ -5198,57 +5198,31 @@ var sqlui = (function (exports) {
|
|
5198
5198
|
parent.length += view.length;
|
5199
5199
|
}
|
5200
5200
|
function coordsInChildren(view, pos, side) {
|
5201
|
-
|
5202
|
-
return fallbackRect(view);
|
5203
|
-
return (side <= 0 ? coordsInChildrenBefore : coordsInChildrenAfter)(view, pos);
|
5204
|
-
}
|
5205
|
-
function coordsInChildrenBefore(view, pos) {
|
5206
|
-
// Find the last leaf in the tree that touches pos and doesn't have getSide() > 0
|
5207
|
-
let found = null, foundPos = -1;
|
5201
|
+
let before = null, beforePos = -1, after = null, afterPos = -1;
|
5208
5202
|
function scan(view, pos) {
|
5209
5203
|
for (let i = 0, off = 0; i < view.children.length && off <= pos; i++) {
|
5210
5204
|
let child = view.children[i], end = off + child.length;
|
5211
5205
|
if (end >= pos) {
|
5212
5206
|
if (child.children.length) {
|
5213
|
-
|
5214
|
-
return true;
|
5207
|
+
scan(child, pos - off);
|
5215
5208
|
}
|
5216
|
-
else if (end
|
5217
|
-
|
5218
|
-
|
5219
|
-
found = child;
|
5220
|
-
foundPos = pos - off;
|
5221
|
-
}
|
5222
|
-
}
|
5223
|
-
off = end;
|
5224
|
-
}
|
5225
|
-
}
|
5226
|
-
scan(view, pos);
|
5227
|
-
return found ? found.coordsAt(Math.max(0, foundPos), -1) : coordsInChildrenAfter(view, pos);
|
5228
|
-
}
|
5229
|
-
function coordsInChildrenAfter(view, pos) {
|
5230
|
-
// Find the first leaf in the tree that touches pos and doesn't have getSide() < 0
|
5231
|
-
let found = null, foundPos = -1;
|
5232
|
-
function scan(view, pos) {
|
5233
|
-
for (let i = view.children.length - 1, off = view.length; i >= 0 && off >= pos; i--) {
|
5234
|
-
let child = view.children[i];
|
5235
|
-
off -= child.length;
|
5236
|
-
if (off <= pos) {
|
5237
|
-
if (child.children.length) {
|
5238
|
-
if (scan(child, pos - off))
|
5239
|
-
return true;
|
5209
|
+
else if (!after && (end > pos || off == end && child.getSide() > 0)) {
|
5210
|
+
after = child;
|
5211
|
+
afterPos = pos - off;
|
5240
5212
|
}
|
5241
|
-
else if (off
|
5242
|
-
|
5243
|
-
|
5244
|
-
found = child;
|
5245
|
-
foundPos = pos - off;
|
5213
|
+
else if (off < pos || (off == end && child.getSide() < 0)) {
|
5214
|
+
before = child;
|
5215
|
+
beforePos = pos - off;
|
5246
5216
|
}
|
5247
5217
|
}
|
5218
|
+
off = end;
|
5248
5219
|
}
|
5249
5220
|
}
|
5250
5221
|
scan(view, pos);
|
5251
|
-
|
5222
|
+
let target = (side < 0 ? before : after) || before || after;
|
5223
|
+
if (target)
|
5224
|
+
return target.coordsAt(Math.max(0, target == before ? beforePos : afterPos), side);
|
5225
|
+
return fallbackRect(view);
|
5252
5226
|
}
|
5253
5227
|
function fallbackRect(view) {
|
5254
5228
|
let last = view.dom.lastChild;
|
@@ -9713,6 +9687,15 @@ var sqlui = (function (exports) {
|
|
9713
9687
|
newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
|
9714
9688
|
change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
|
9715
9689
|
}
|
9690
|
+
else if (browser.chrome && change && change.from == change.to && change.from == sel.head &&
|
9691
|
+
change.insert.toString() == "\n " && view.lineWrapping) {
|
9692
|
+
// In Chrome, if you insert a space at the start of a wrapped
|
9693
|
+
// line, it will actually insert a newline and a space, causing a
|
9694
|
+
// bogus new line to be created in CodeMirror (#968)
|
9695
|
+
if (newSel)
|
9696
|
+
newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
|
9697
|
+
change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
|
9698
|
+
}
|
9716
9699
|
if (change) {
|
9717
9700
|
let startState = view.state;
|
9718
9701
|
if (browser.ios && view.inputState.flushIOSKey(view))
|
@@ -10637,17 +10620,19 @@ var sqlui = (function (exports) {
|
|
10637
10620
|
logException(this.state, e);
|
10638
10621
|
}
|
10639
10622
|
}
|
10640
|
-
if (this.viewState.
|
10641
|
-
|
10642
|
-
|
10643
|
-
|
10644
|
-
}
|
10645
|
-
else {
|
10646
|
-
let diff = this.viewState.lineBlockAt(refBlock.from).top - refBlock.top;
|
10647
|
-
if (diff > 1 || diff < -1) {
|
10648
|
-
this.scrollDOM.scrollTop += diff;
|
10623
|
+
if (this.viewState.editorHeight) {
|
10624
|
+
if (this.viewState.scrollTarget) {
|
10625
|
+
this.docView.scrollIntoView(this.viewState.scrollTarget);
|
10626
|
+
this.viewState.scrollTarget = null;
|
10649
10627
|
scrolled = true;
|
10650
10628
|
}
|
10629
|
+
else {
|
10630
|
+
let diff = this.viewState.lineBlockAt(refBlock.from).top - refBlock.top;
|
10631
|
+
if (diff > 1 || diff < -1) {
|
10632
|
+
this.scrollDOM.scrollTop += diff;
|
10633
|
+
scrolled = true;
|
10634
|
+
}
|
10635
|
+
}
|
10651
10636
|
}
|
10652
10637
|
if (redrawn)
|
10653
10638
|
this.docView.updateSelection(true);
|
@@ -12129,7 +12114,10 @@ var sqlui = (function (exports) {
|
|
12129
12114
|
for (let i = startLine; i <= endLine; i++) {
|
12130
12115
|
let line = state.doc.line(i);
|
12131
12116
|
let start = findColumn(line.text, startCol, state.tabSize, true);
|
12132
|
-
if (start
|
12117
|
+
if (start < 0) {
|
12118
|
+
ranges.push(EditorSelection.cursor(line.to));
|
12119
|
+
}
|
12120
|
+
else {
|
12133
12121
|
let end = findColumn(line.text, endCol, state.tabSize);
|
12134
12122
|
ranges.push(EditorSelection.range(line.from + start, line.from + end));
|
12135
12123
|
}
|
@@ -12241,6 +12229,7 @@ var sqlui = (function (exports) {
|
|
12241
12229
|
this.tooltipViews = this.tooltips.map(createTooltipView);
|
12242
12230
|
}
|
12243
12231
|
update(update) {
|
12232
|
+
var _a;
|
12244
12233
|
let input = update.state.facet(this.facet);
|
12245
12234
|
let tooltips = input.filter(x => x);
|
12246
12235
|
if (input === this.input) {
|
@@ -12269,8 +12258,10 @@ var sqlui = (function (exports) {
|
|
12269
12258
|
}
|
12270
12259
|
}
|
12271
12260
|
for (let t of this.tooltipViews)
|
12272
|
-
if (tooltipViews.indexOf(t) < 0)
|
12261
|
+
if (tooltipViews.indexOf(t) < 0) {
|
12273
12262
|
t.dom.remove();
|
12263
|
+
(_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
|
12264
|
+
}
|
12274
12265
|
this.input = input;
|
12275
12266
|
this.tooltips = tooltips;
|
12276
12267
|
this.tooltipViews = tooltipViews;
|
@@ -12383,11 +12374,13 @@ var sqlui = (function (exports) {
|
|
12383
12374
|
return tooltipView;
|
12384
12375
|
}
|
12385
12376
|
destroy() {
|
12386
|
-
var _a;
|
12377
|
+
var _a, _b;
|
12387
12378
|
this.view.win.removeEventListener("resize", this.measureSoon);
|
12388
|
-
for (let
|
12389
|
-
dom.remove();
|
12390
|
-
|
12379
|
+
for (let tooltipView of this.manager.tooltipViews) {
|
12380
|
+
tooltipView.dom.remove();
|
12381
|
+
(_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);
|
12382
|
+
}
|
12383
|
+
(_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
12391
12384
|
clearTimeout(this.measureTimeout);
|
12392
12385
|
}
|
12393
12386
|
readMeasure() {
|
@@ -14811,23 +14804,25 @@ var sqlui = (function (exports) {
|
|
14811
14804
|
let set = [], tag = new Tag(set, base, mods);
|
14812
14805
|
for (let m of mods)
|
14813
14806
|
m.instances.push(tag);
|
14814
|
-
let configs =
|
14807
|
+
let configs = powerSet(mods);
|
14815
14808
|
for (let parent of base.set)
|
14816
|
-
|
14817
|
-
|
14809
|
+
if (!parent.modified.length)
|
14810
|
+
for (let config of configs)
|
14811
|
+
set.push(Modifier.get(parent, config));
|
14818
14812
|
return tag;
|
14819
14813
|
}
|
14820
14814
|
}
|
14821
14815
|
function sameArray(a, b) {
|
14822
14816
|
return a.length == b.length && a.every((x, i) => x == b[i]);
|
14823
14817
|
}
|
14824
|
-
function
|
14825
|
-
let
|
14818
|
+
function powerSet(array) {
|
14819
|
+
let sets = [[]];
|
14826
14820
|
for (let i = 0; i < array.length; i++) {
|
14827
|
-
for (let
|
14828
|
-
|
14821
|
+
for (let j = 0, e = sets.length; j < e; j++) {
|
14822
|
+
sets.push(sets[j].concat(array[i]));
|
14823
|
+
}
|
14829
14824
|
}
|
14830
|
-
return
|
14825
|
+
return sets.sort((a, b) => b.length - a.length);
|
14831
14826
|
}
|
14832
14827
|
/// This function is used to add a set of tags to a language syntax
|
14833
14828
|
/// via [`NodeSet.extend`](#common.NodeSet.extend) or
|
@@ -18630,7 +18625,7 @@ var sqlui = (function (exports) {
|
|
18630
18625
|
if (match) {
|
18631
18626
|
let from = this.curLineStart + match.index, to = from + match[0].length;
|
18632
18627
|
this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
|
18633
|
-
if (from == this.curLine.length)
|
18628
|
+
if (from == this.curLineStart + this.curLine.length)
|
18634
18629
|
this.nextLine();
|
18635
18630
|
if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {
|
18636
18631
|
this.value = { from, to, match };
|
@@ -19015,10 +19010,17 @@ var sqlui = (function (exports) {
|
|
19015
19010
|
this.regexp = !!config.regexp;
|
19016
19011
|
this.replace = config.replace || "";
|
19017
19012
|
this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
|
19018
|
-
this.unquoted = this.
|
19013
|
+
this.unquoted = this.unquote(this.search);
|
19019
19014
|
this.wholeWord = !!config.wholeWord;
|
19020
19015
|
}
|
19021
19016
|
/**
|
19017
|
+
@internal
|
19018
|
+
*/
|
19019
|
+
unquote(text) {
|
19020
|
+
return this.literal ? text :
|
19021
|
+
text.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
|
19022
|
+
}
|
19023
|
+
/**
|
19022
19024
|
Compare this query to another query.
|
19023
19025
|
*/
|
19024
19026
|
eq(other) {
|
@@ -19092,7 +19094,7 @@ var sqlui = (function (exports) {
|
|
19092
19094
|
return this.prevMatchInRange(state, 0, curFrom) ||
|
19093
19095
|
this.prevMatchInRange(state, curTo, state.doc.length);
|
19094
19096
|
}
|
19095
|
-
getReplacement(_result) { return this.spec.replace; }
|
19097
|
+
getReplacement(_result) { return this.spec.unquote(this.spec.replace); }
|
19096
19098
|
matchAll(state, limit) {
|
19097
19099
|
let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
19098
19100
|
while (!cursor.next().done) {
|
@@ -19151,10 +19153,10 @@ var sqlui = (function (exports) {
|
|
19151
19153
|
this.prevMatchInRange(state, curTo, state.doc.length);
|
19152
19154
|
}
|
19153
19155
|
getReplacement(result) {
|
19154
|
-
return this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
|
19156
|
+
return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
|
19155
19157
|
: i == "&" ? result.match[0]
|
19156
19158
|
: i != "0" && +i < result.match.length ? result.match[i]
|
19157
|
-
: m);
|
19159
|
+
: m));
|
19158
19160
|
}
|
19159
19161
|
matchAll(state, limit) {
|
19160
19162
|
let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
@@ -19446,6 +19448,7 @@ var sqlui = (function (exports) {
|
|
19446
19448
|
"aria-label": phrase(view, "Find"),
|
19447
19449
|
class: "cm-textfield",
|
19448
19450
|
name: "search",
|
19451
|
+
form: "",
|
19449
19452
|
"main-field": "true",
|
19450
19453
|
onchange: this.commit,
|
19451
19454
|
onkeyup: this.commit
|
@@ -19456,24 +19459,28 @@ var sqlui = (function (exports) {
|
|
19456
19459
|
"aria-label": phrase(view, "Replace"),
|
19457
19460
|
class: "cm-textfield",
|
19458
19461
|
name: "replace",
|
19462
|
+
form: "",
|
19459
19463
|
onchange: this.commit,
|
19460
19464
|
onkeyup: this.commit
|
19461
19465
|
});
|
19462
19466
|
this.caseField = crelt("input", {
|
19463
19467
|
type: "checkbox",
|
19464
19468
|
name: "case",
|
19469
|
+
form: "",
|
19465
19470
|
checked: query.caseSensitive,
|
19466
19471
|
onchange: this.commit
|
19467
19472
|
});
|
19468
19473
|
this.reField = crelt("input", {
|
19469
19474
|
type: "checkbox",
|
19470
19475
|
name: "re",
|
19476
|
+
form: "",
|
19471
19477
|
checked: query.regexp,
|
19472
19478
|
onchange: this.commit
|
19473
19479
|
});
|
19474
19480
|
this.wordField = crelt("input", {
|
19475
19481
|
type: "checkbox",
|
19476
19482
|
name: "word",
|
19483
|
+
form: "",
|
19477
19484
|
checked: query.wholeWord,
|
19478
19485
|
onchange: this.commit
|
19479
19486
|
});
|
@@ -23266,10 +23273,10 @@ var sqlui = (function (exports) {
|
|
23266
23273
|
Builtin = 24;
|
23267
23274
|
|
23268
23275
|
function isAlpha(ch) {
|
23269
|
-
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */;
|
23276
|
+
return ch >= 65 /* Ch.A */ && ch <= 90 /* Ch.Z */ || ch >= 97 /* Ch.a */ && ch <= 122 /* Ch.z */ || ch >= 48 /* Ch._0 */ && ch <= 57 /* Ch._9 */;
|
23270
23277
|
}
|
23271
23278
|
function isHexDigit(ch) {
|
23272
|
-
return ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch >= 97 /* a */ && ch <= 102 /* f */ || ch >= 65 /* A */ && ch <= 70 /* F */;
|
23279
|
+
return ch >= 48 /* Ch._0 */ && ch <= 57 /* Ch._9 */ || ch >= 97 /* Ch.a */ && ch <= 102 /* Ch.f */ || ch >= 65 /* Ch.A */ && ch <= 70 /* Ch.F */;
|
23273
23280
|
}
|
23274
23281
|
function readLiteral(input, endQuote, backslashEscapes) {
|
23275
23282
|
for (let escaped = false;;) {
|
@@ -23279,7 +23286,7 @@ var sqlui = (function (exports) {
|
|
23279
23286
|
input.advance();
|
23280
23287
|
return;
|
23281
23288
|
}
|
23282
|
-
escaped = backslashEscapes && !escaped && input.next == 92 /* Backslash */;
|
23289
|
+
escaped = backslashEscapes && !escaped && input.next == 92 /* Ch.Backslash */;
|
23283
23290
|
input.advance();
|
23284
23291
|
}
|
23285
23292
|
}
|
@@ -23287,7 +23294,7 @@ var sqlui = (function (exports) {
|
|
23287
23294
|
for (;;) {
|
23288
23295
|
if (input.next < 0 || input.peek(1) < 0)
|
23289
23296
|
return;
|
23290
|
-
if (input.next == 36 /* Dollar */ && input.peek(1) == 36 /* Dollar */) {
|
23297
|
+
if (input.next == 36 /* Ch.Dollar */ && input.peek(1) == 36 /* Ch.Dollar */) {
|
23291
23298
|
input.advance(2);
|
23292
23299
|
return;
|
23293
23300
|
}
|
@@ -23296,7 +23303,7 @@ var sqlui = (function (exports) {
|
|
23296
23303
|
}
|
23297
23304
|
function readWord(input, result) {
|
23298
23305
|
for (;;) {
|
23299
|
-
if (input.next != 95 /* Underscore */ && !isAlpha(input.next))
|
23306
|
+
if (input.next != 95 /* Ch.Underscore */ && !isAlpha(input.next))
|
23300
23307
|
break;
|
23301
23308
|
if (result != null)
|
23302
23309
|
result += String.fromCharCode(input.next);
|
@@ -23305,7 +23312,7 @@ var sqlui = (function (exports) {
|
|
23305
23312
|
return result;
|
23306
23313
|
}
|
23307
23314
|
function readWordOrQuoted(input) {
|
23308
|
-
if (input.next == 39 /* SingleQuote */ || input.next == 34 /* DoubleQuote */ || input.next == 96 /* Backtick */) {
|
23315
|
+
if (input.next == 39 /* Ch.SingleQuote */ || input.next == 34 /* Ch.DoubleQuote */ || input.next == 96 /* Ch.Backtick */) {
|
23309
23316
|
let quote = input.next;
|
23310
23317
|
input.advance();
|
23311
23318
|
readLiteral(input, quote, false);
|
@@ -23315,33 +23322,33 @@ var sqlui = (function (exports) {
|
|
23315
23322
|
}
|
23316
23323
|
}
|
23317
23324
|
function readBits(input, endQuote) {
|
23318
|
-
while (input.next == 48 /* _0 */ || input.next == 49 /* _1 */)
|
23325
|
+
while (input.next == 48 /* Ch._0 */ || input.next == 49 /* Ch._1 */)
|
23319
23326
|
input.advance();
|
23320
23327
|
if (endQuote && input.next == endQuote)
|
23321
23328
|
input.advance();
|
23322
23329
|
}
|
23323
23330
|
function readNumber(input, sawDot) {
|
23324
23331
|
for (;;) {
|
23325
|
-
if (input.next == 46 /* Dot */) {
|
23332
|
+
if (input.next == 46 /* Ch.Dot */) {
|
23326
23333
|
if (sawDot)
|
23327
23334
|
break;
|
23328
23335
|
sawDot = true;
|
23329
23336
|
}
|
23330
|
-
else if (input.next < 48 /* _0 */ || input.next > 57 /* _9 */) {
|
23337
|
+
else if (input.next < 48 /* Ch._0 */ || input.next > 57 /* Ch._9 */) {
|
23331
23338
|
break;
|
23332
23339
|
}
|
23333
23340
|
input.advance();
|
23334
23341
|
}
|
23335
|
-
if (input.next == 69 /* E */ || input.next == 101 /* e */) {
|
23342
|
+
if (input.next == 69 /* Ch.E */ || input.next == 101 /* Ch.e */) {
|
23336
23343
|
input.advance();
|
23337
|
-
if (input.next == 43 /* Plus */ || input.next == 45 /* Dash */)
|
23344
|
+
if (input.next == 43 /* Ch.Plus */ || input.next == 45 /* Ch.Dash */)
|
23338
23345
|
input.advance();
|
23339
|
-
while (input.next >= 48 /* _0 */ && input.next <= 57 /* _9 */)
|
23346
|
+
while (input.next >= 48 /* Ch._0 */ && input.next <= 57 /* Ch._9 */)
|
23340
23347
|
input.advance();
|
23341
23348
|
}
|
23342
23349
|
}
|
23343
23350
|
function eol(input) {
|
23344
|
-
while (!(input.next < 0 || input.next == 10 /* Newline */))
|
23351
|
+
while (!(input.next < 0 || input.next == 10 /* Ch.Newline */))
|
23345
23352
|
input.advance();
|
23346
23353
|
}
|
23347
23354
|
function inString(ch, str) {
|
@@ -23401,31 +23408,31 @@ var sqlui = (function (exports) {
|
|
23401
23408
|
input.advance();
|
23402
23409
|
input.acceptToken(whitespace);
|
23403
23410
|
}
|
23404
|
-
else if (next == 36 /* Dollar */ && input.next == 36 /* Dollar */ && d.doubleDollarStrings) {
|
23411
|
+
else if (next == 36 /* Ch.Dollar */ && input.next == 36 /* Ch.Dollar */ && d.doubleDollarStrings) {
|
23405
23412
|
readDoubleDollarLiteral(input);
|
23406
23413
|
input.acceptToken(String$1);
|
23407
23414
|
}
|
23408
|
-
else if (next == 39 /* SingleQuote */ || next == 34 /* DoubleQuote */ && d.doubleQuotedStrings) {
|
23415
|
+
else if (next == 39 /* Ch.SingleQuote */ || next == 34 /* Ch.DoubleQuote */ && d.doubleQuotedStrings) {
|
23409
23416
|
readLiteral(input, next, d.backslashEscapes);
|
23410
23417
|
input.acceptToken(String$1);
|
23411
23418
|
}
|
23412
|
-
else if (next == 35 /* Hash */ && d.hashComments ||
|
23413
|
-
next == 47 /* Slash */ && input.next == 47 /* Slash */ && d.slashComments) {
|
23419
|
+
else if (next == 35 /* Ch.Hash */ && d.hashComments ||
|
23420
|
+
next == 47 /* Ch.Slash */ && input.next == 47 /* Ch.Slash */ && d.slashComments) {
|
23414
23421
|
eol(input);
|
23415
23422
|
input.acceptToken(LineComment);
|
23416
23423
|
}
|
23417
|
-
else if (next == 45 /* Dash */ && input.next == 45 /* Dash */ &&
|
23418
|
-
(!d.spaceAfterDashes || input.peek(
|
23424
|
+
else if (next == 45 /* Ch.Dash */ && input.next == 45 /* Ch.Dash */ &&
|
23425
|
+
(!d.spaceAfterDashes || input.peek(1) == 32 /* Ch.Space */)) {
|
23419
23426
|
eol(input);
|
23420
23427
|
input.acceptToken(LineComment);
|
23421
23428
|
}
|
23422
|
-
else if (next == 47 /* Slash */ && input.next == 42 /* Star */) {
|
23429
|
+
else if (next == 47 /* Ch.Slash */ && input.next == 42 /* Ch.Star */) {
|
23423
23430
|
input.advance();
|
23424
23431
|
for (let prev = -1, depth = 1;;) {
|
23425
23432
|
if (input.next < 0)
|
23426
23433
|
break;
|
23427
23434
|
input.advance();
|
23428
|
-
if (prev == 42 /* Star */ && input.next == 47 /* Slash */) {
|
23435
|
+
if (prev == 42 /* Ch.Star */ && input.next == 47 /* Ch.Slash */) {
|
23429
23436
|
depth--;
|
23430
23437
|
if (!depth) {
|
23431
23438
|
input.advance();
|
@@ -23433,7 +23440,7 @@ var sqlui = (function (exports) {
|
|
23433
23440
|
}
|
23434
23441
|
prev = -1;
|
23435
23442
|
}
|
23436
|
-
else if (prev == 47 /* Slash */ && input.next == 42 /* Star */) {
|
23443
|
+
else if (prev == 47 /* Ch.Slash */ && input.next == 42 /* Ch.Star */) {
|
23437
23444
|
depth++;
|
23438
23445
|
prev = -1;
|
23439
23446
|
}
|
@@ -23443,21 +23450,21 @@ var sqlui = (function (exports) {
|
|
23443
23450
|
}
|
23444
23451
|
input.acceptToken(BlockComment);
|
23445
23452
|
}
|
23446
|
-
else if ((next == 101 /* e */ || next == 69 /* E */) && input.next == 39 /* SingleQuote */) {
|
23453
|
+
else if ((next == 101 /* Ch.e */ || next == 69 /* Ch.E */) && input.next == 39 /* Ch.SingleQuote */) {
|
23447
23454
|
input.advance();
|
23448
|
-
readLiteral(input, 39 /* SingleQuote */, true);
|
23455
|
+
readLiteral(input, 39 /* Ch.SingleQuote */, true);
|
23449
23456
|
}
|
23450
|
-
else if ((next == 110 /* n */ || next == 78 /* N */) && input.next == 39 /* SingleQuote */ &&
|
23457
|
+
else if ((next == 110 /* Ch.n */ || next == 78 /* Ch.N */) && input.next == 39 /* Ch.SingleQuote */ &&
|
23451
23458
|
d.charSetCasts) {
|
23452
23459
|
input.advance();
|
23453
|
-
readLiteral(input, 39 /* SingleQuote */, d.backslashEscapes);
|
23460
|
+
readLiteral(input, 39 /* Ch.SingleQuote */, d.backslashEscapes);
|
23454
23461
|
input.acceptToken(String$1);
|
23455
23462
|
}
|
23456
|
-
else if (next == 95 /* Underscore */ && d.charSetCasts) {
|
23463
|
+
else if (next == 95 /* Ch.Underscore */ && d.charSetCasts) {
|
23457
23464
|
for (let i = 0;; i++) {
|
23458
|
-
if (input.next == 39 /* SingleQuote */ && i > 1) {
|
23465
|
+
if (input.next == 39 /* Ch.SingleQuote */ && i > 1) {
|
23459
23466
|
input.advance();
|
23460
|
-
readLiteral(input, 39 /* SingleQuote */, d.backslashEscapes);
|
23467
|
+
readLiteral(input, 39 /* Ch.SingleQuote */, d.backslashEscapes);
|
23461
23468
|
input.acceptToken(String$1);
|
23462
23469
|
break;
|
23463
23470
|
}
|
@@ -23466,33 +23473,33 @@ var sqlui = (function (exports) {
|
|
23466
23473
|
input.advance();
|
23467
23474
|
}
|
23468
23475
|
}
|
23469
|
-
else if (next == 40 /* ParenL */) {
|
23476
|
+
else if (next == 40 /* Ch.ParenL */) {
|
23470
23477
|
input.acceptToken(ParenL);
|
23471
23478
|
}
|
23472
|
-
else if (next == 41 /* ParenR */) {
|
23479
|
+
else if (next == 41 /* Ch.ParenR */) {
|
23473
23480
|
input.acceptToken(ParenR);
|
23474
23481
|
}
|
23475
|
-
else if (next == 123 /* BraceL */) {
|
23482
|
+
else if (next == 123 /* Ch.BraceL */) {
|
23476
23483
|
input.acceptToken(BraceL);
|
23477
23484
|
}
|
23478
|
-
else if (next == 125 /* BraceR */) {
|
23485
|
+
else if (next == 125 /* Ch.BraceR */) {
|
23479
23486
|
input.acceptToken(BraceR);
|
23480
23487
|
}
|
23481
|
-
else if (next == 91 /* BracketL */) {
|
23488
|
+
else if (next == 91 /* Ch.BracketL */) {
|
23482
23489
|
input.acceptToken(BracketL);
|
23483
23490
|
}
|
23484
|
-
else if (next == 93 /* BracketR */) {
|
23491
|
+
else if (next == 93 /* Ch.BracketR */) {
|
23485
23492
|
input.acceptToken(BracketR);
|
23486
23493
|
}
|
23487
|
-
else if (next == 59 /* Semi */) {
|
23494
|
+
else if (next == 59 /* Ch.Semi */) {
|
23488
23495
|
input.acceptToken(Semi);
|
23489
23496
|
}
|
23490
|
-
else if (d.unquotedBitLiterals && next == 48 /* _0 */ && input.next == 98 /* b */) {
|
23497
|
+
else if (d.unquotedBitLiterals && next == 48 /* Ch._0 */ && input.next == 98 /* Ch.b */) {
|
23491
23498
|
input.advance();
|
23492
23499
|
readBits(input);
|
23493
23500
|
input.acceptToken(Bits);
|
23494
23501
|
}
|
23495
|
-
else if ((next == 98 /* b */ || next == 66 /* B */) && (input.next == 39 /* SingleQuote */ || input.next == 34 /* DoubleQuote */)) {
|
23502
|
+
else if ((next == 98 /* Ch.b */ || next == 66 /* Ch.B */) && (input.next == 39 /* Ch.SingleQuote */ || input.next == 34 /* Ch.DoubleQuote */)) {
|
23496
23503
|
const quoteStyle = input.next;
|
23497
23504
|
input.advance();
|
23498
23505
|
if (d.treatBitsAsBytes) {
|
@@ -23504,24 +23511,24 @@ var sqlui = (function (exports) {
|
|
23504
23511
|
input.acceptToken(Bits);
|
23505
23512
|
}
|
23506
23513
|
}
|
23507
|
-
else if (next == 48 /* _0 */ && (input.next == 120 /* x */ || input.next == 88 /* X */) ||
|
23508
|
-
(next == 120 /* x */ || next == 88 /* X */) && input.next == 39 /* SingleQuote */) {
|
23509
|
-
let quoted = input.next == 39 /* SingleQuote */;
|
23514
|
+
else if (next == 48 /* Ch._0 */ && (input.next == 120 /* Ch.x */ || input.next == 88 /* Ch.X */) ||
|
23515
|
+
(next == 120 /* Ch.x */ || next == 88 /* Ch.X */) && input.next == 39 /* Ch.SingleQuote */) {
|
23516
|
+
let quoted = input.next == 39 /* Ch.SingleQuote */;
|
23510
23517
|
input.advance();
|
23511
23518
|
while (isHexDigit(input.next))
|
23512
23519
|
input.advance();
|
23513
|
-
if (quoted && input.next == 39 /* SingleQuote */)
|
23520
|
+
if (quoted && input.next == 39 /* Ch.SingleQuote */)
|
23514
23521
|
input.advance();
|
23515
23522
|
input.acceptToken(Number);
|
23516
23523
|
}
|
23517
|
-
else if (next == 46 /* Dot */ && input.next >= 48 /* _0 */ && input.next <= 57 /* _9 */) {
|
23524
|
+
else if (next == 46 /* Ch.Dot */ && input.next >= 48 /* Ch._0 */ && input.next <= 57 /* Ch._9 */) {
|
23518
23525
|
readNumber(input, true);
|
23519
23526
|
input.acceptToken(Number);
|
23520
23527
|
}
|
23521
|
-
else if (next == 46 /* Dot */) {
|
23528
|
+
else if (next == 46 /* Ch.Dot */) {
|
23522
23529
|
input.acceptToken(Dot);
|
23523
23530
|
}
|
23524
|
-
else if (next >= 48 /* _0 */ && next <= 57 /* _9 */) {
|
23531
|
+
else if (next >= 48 /* Ch._0 */ && next <= 57 /* Ch._9 */) {
|
23525
23532
|
readNumber(input, false);
|
23526
23533
|
input.acceptToken(Number);
|
23527
23534
|
}
|
@@ -23540,12 +23547,12 @@ var sqlui = (function (exports) {
|
|
23540
23547
|
readLiteral(input, next, false);
|
23541
23548
|
input.acceptToken(QuotedIdentifier);
|
23542
23549
|
}
|
23543
|
-
else if (next == 58 /* Colon */ || next == 44 /* Comma */) {
|
23550
|
+
else if (next == 58 /* Ch.Colon */ || next == 44 /* Ch.Comma */) {
|
23544
23551
|
input.acceptToken(Punctuation);
|
23545
23552
|
}
|
23546
23553
|
else if (isAlpha(next)) {
|
23547
23554
|
let word = readWord(input, String.fromCharCode(next));
|
23548
|
-
input.acceptToken(input.next == 46 /* Dot */ ? Identifier : (_a = d.words[word.toLowerCase()]) !== null && _a !== void 0 ? _a : Identifier);
|
23555
|
+
input.acceptToken(input.next == 46 /* Ch.Dot */ ? Identifier : (_a = d.words[word.toLowerCase()]) !== null && _a !== void 0 ? _a : Identifier);
|
23549
23556
|
}
|
23550
23557
|
});
|
23551
23558
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Dower
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: sinatra
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,7 +169,8 @@ files:
|
|
155
169
|
homepage: https://github.com/nicholasdower/sqlui
|
156
170
|
licenses:
|
157
171
|
- MIT
|
158
|
-
metadata:
|
172
|
+
metadata:
|
173
|
+
rubygems_mfa_required: 'true'
|
159
174
|
post_install_message:
|
160
175
|
rdoc_options: []
|
161
176
|
require_paths:
|
@@ -164,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
179
|
requirements:
|
165
180
|
- - ">="
|
166
181
|
- !ruby/object:Gem::Version
|
167
|
-
version:
|
182
|
+
version: 3.0.0
|
168
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
184
|
requirements:
|
170
185
|
- - ">="
|