question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getRulesFromSQL() : Auto detect field IDs by field names using the already defined config.

See original GitHub issue

As per the last comment on issue #452 , I would like to ask for getRulesFromSQL() to be modified to determine the correct IDs based on the Field Names. At first, this was only going to be a request for convenience sake, but I have just discovered an issue where this is actually very important (at least to me anyway) and will probably need to involve the SQL parser being updated as well:

I have successfully been able to do a joined query by basically setting the field names in my config with a prefix… Example:

filters: [
	{ id: 'booking-id', field: '"B"."Id"', label: 'Booking: ID' },
	{ id: 'booking-code', field: '"B"."Code"', label: 'Booking: Code' },
	{ id: 'booking-date', field: '"B"."BookingDate"', label: 'Booking: Date' },
	{ id: 'booking-destination', field: '"B"."Destination"', label: 'Booking: Destination' },
	//etc
	{ id: 'customer-id', field: '"C"."Id"', label: 'Customer: ID' },
	{ id: 'customer-email', field: '"C"."Email"', label: 'Customer: Email' },
	//etc
]

Then, in the backend, I simply create my SQL query as follows:

SELECT *
FROM "Bookings" AS "B"
INNER JOIN "Customers" "C" ON "C"."Id" = "B"."CustomerId"
WHERE <Query From QueryBuilder Goes Here>

It works beautifully. But then when I want to load a saved query, it doesn’t work because this is obviously not supported in the SQL parser. I would like to suggest that QueryBuilder already has the field definitions, so in theory it shouldn’t be too hard to simply match each field name with an ID automatically. For example, “C”.“Id” would be matched to the ID “customer-id”.

What’s the possibility of having this done?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mistic100commented, Sep 23, 2019
0reactions
gordon-mattcommented, Sep 23, 2019

Hi there. It’s been 2 years since I opened this request. I am working on a new project that will be using this Query Builder… and I was just looking at this issue again and noticed that the last thing that happened here was you made a fix, but only for Mongo. Is this fix now applied to SQL as well?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to find any custom field's IDs | Jira
Using URL · Navigate to Settings ( ) > Issues > Custom fields under the Fields section · Click on the More (⋯)...
Read more >
Find Items Error - Discussion - BMC Community
Good afternoon, I am trying to use the AMP-AD-BMC-Remedy-ARS process "find items" and am ... Can you try using the Field-Name instead of...
Read more >
Return fieldname from another table based on ID
My question, is there a query that will return the field names for the second table(from the first table) instead of the CF####...
Read more >
Frequently Asked Questions (FAQ) | ent
How to define a network address field in PostgreSQL? How to customize time fields to type DATETIME in MySQL? How to use a...
Read more >
Datasets - BigML.com
For items fields which have many different categorical values per instance separated by non-alphanumeric characters, BigML tries to automatically detect ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found