New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
would it make sense to allow js {}
variables in config {}
#1704
Comments
js {}
js {}
variables in config {}
Thanks @andres-lowrie for your issue, I'm also very interested by this problem. I've started to look at the compiler.ts file in order to understand where js variables were resolved. I think I would make a lot of sense to resolve constant in the js block before the config one, but I can't really understand how hard it could be. We also had the discussion here : https://www.googlecloudcommunity.com/gc/Data-Analytics/Ho-to-reference-a-variable-from-js-script-within-sqlx-file/m-p/730521#M5442 My usage :
@Ekrekr Maybe you can point out the steps in the compiler where we could look at ? :) |
For scoping reasons, That said, there is nothing stopping you doing something like:
|
ahh.. good to know. That's much better than splitting across, sweet |
So for example say I have a file structure like this
and let's say that
sharedLogicStuff.js
looks like thiswhat I'm hinting is being able to do something like this in the
.sqlx
filescurrently that doesn't work. I get back
colsToAppearInManyPlace is not defined
which I'm assuming is by designI'm wondering if being able to reference
js {}
stuff in theconfig {}
makes sense from a big picture dataform design idea in order to add it as a feature.In the use case I laid out, the goal is to keep the shared stuff close to the
sqlx
files to make it easier to find/edit the shared logic when working on a table. Imagine the.js
file having a bunch of other variables and snippets that's used in the actual "sqlx body" as wellCurrently what I have to do to in order to share declarations of variables is split out the declarations across
includes/
anddefinitions
depending on where I want to use them in the definitions (sqlx files)it's a bit cumbersome and a bit complex (cognitive load wise) to have to split out variables/logic/etc into 2 locations in order to be able to reference them in different places within the
.sqlx
file; would be nice if both the "config {}" block and the "sqlx block" had access to thejs {}
as well as theincludes
The text was updated successfully, but these errors were encountered: