mirror of
https://github.com/discourse/discourse-data-explorer.git
synced 2025-03-09 13:24:53 +00:00
Fix param-extraction
This commit is contained in:
parent
a81f8495b0
commit
baeb747fcb
@ -1,6 +1,6 @@
|
|||||||
<h3>Queries</h3>
|
<h3>Queries</h3>
|
||||||
<div class="query-list">
|
<div class="query-list">
|
||||||
{{combo-box valueAttribute="id" value=selectedQueryId nameProperty="listName" content=content castInteger="true"}}
|
{{combo-box valueAttribute="id" value=selectedQueryId nameProperty="listName" content=content castInteger="true" nameChanges="true"}}
|
||||||
{{d-button action="showCreate" icon="plus" class="no-text"}}
|
{{d-button action="showCreate" icon="plus" class="no-text"}}
|
||||||
{{d-button action="importQuery" label="explorer.import.label" icon="upload"}}
|
{{d-button action="importQuery" label="explorer.import.label" icon="upload"}}
|
||||||
</div>
|
</div>
|
||||||
|
10
plugin.rb
10
plugin.rb
@ -47,9 +47,13 @@ after_initialize do
|
|||||||
# (The first name is $0.)
|
# (The first name is $0.)
|
||||||
def self.extract_params(sql)
|
def self.extract_params(sql)
|
||||||
names = []
|
names = []
|
||||||
new_sql = sql.gsub(/:([a-z_]+)/) do |_|
|
new_sql = sql.gsub(/(:?):([a-z_]+)/) do |_|
|
||||||
names << $1
|
if $1 == ':' # skip casts
|
||||||
"$#{names.length - 1}"
|
$&
|
||||||
|
else
|
||||||
|
names << $1
|
||||||
|
"$#{names.length - 1}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
{sql: new_sql, names: names}
|
{sql: new_sql, names: names}
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user