alasql


AlaSQL: Getting where opperands


I have a specific request that I'm rather sure it's not trivial, but thought of asking just in case. If I have any query with WHERE condition:
SELECT * FROM table1 WHERE a = b AND a->fn(b->c) > 0
I would like to know all the operands that take part in WHERE, in this case ['a', 'b', 'a->fn(b->c)', 0].
The reason is that I would want to keep track of those values and if any changes then I would just re-evaluate the query.
You can use alasql.parse() function to produce Abstract Syntax Tree from SQL statement. To print part of the tree from WHERE clause of SELECT statement please use:
var ast = alasql.parse('SELECT * FROM table1 WHERE a = b AND a->fn(b->c) > 0');
console.log(ast.statements[0].where);
Then you will see the tree structure.
{"expression":
{"left":
{"left": {"columnid":"a"},"op":"=", "right":{"columnid":"b"}},
"op":"AND",
"right":{"left":
{"left":{"columnid":"a"},
"op":"->",
"right":
{"funcid":"fn","args":[
{"left":{"columnid":"b"},
"op":"->",
"right":"c"}
]}},
"op":">",
"right":{"value":0}}}}
You can walk along this tree to collect all arguments. Each node is an object of yy.xxx types, so you can test it:
if(node instanceof yy.Column) // then process as the column
Is this answer for your question?

Related Links

how to change font as bold in excel file using alasql?
AlaSQL can you use DISTINCT with SEARCH
Can one use CSV as an in-memory database with alasql?
Export the data to excel & formatting that as requirements
determining what array elements were removed
return alasql informational results
INSERT/UPDATE existing object?
How to insert data in google spreadsheet with tabletop?
How can I export to excel using alaql to multiple sheets AND have different display options for each sheet
AlaSQL saved database location
running two queries and then joining the results alasql promise notation
parent and child key in alasql rollup functions
Alasql select in arrary of array with uknown index
Alasql Best Practices
Alasql - Having columns with sub-columns
AlaSQL: Getting where opperands

Categories

HOME
oop
alasql
typo3
oracle-sqldeveloper
pyspark
fortran
postgresql-9.3
microcontroller
postsharp
hex
css-selectors
autocad
wavefront
google-api-oauth
restheart
cracking
ejb-3.0
theory
aspectj
vichuploaderbundle
android-notifications
nsoperation
ajaxcontroltoolkit
xna
beaker-notebook
scrapy-spider
android-xml
inspec
rollupjs
dynamics-ax-2012-r3
cqlsh
vtd-xml
selenium3
ios-autolayout
circle
epub
http-proxy
kofax
framebuffer
idea-plugin
google-chrome-console
uitextview
paperclip
wufoo
nshttpurlresponse
f#-fake
reqif
anonymous-function
serverless-architecture
cloudconvert
standard-error
cancan
dotnet-cli
opticalflow
critical-section
multi-select
bipartite
turbolinks
papyrus
tinybox2
gdi
db2-zos
system-integration
sbt-proguard
chomsky-normal-form
ooad
matlab-engine
controlpanel
webservices-client
libgcrypt
gitk
redquerybuilder
transport
self-join
page-flipping
eggplant
transparentproxy
tidesdk
gcc-warning
genero
veeam
chrome-mobile
cl.exe
sync
disparity-mapping
opencobol
sqldatasource
ekevent
mysql-error-1146
kendo-window
listpicker
wpa
states
bindinglist
diazo
execjs
xpolog
overlays
javah
nstoolbar
web-search
file-icons

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile