Skip to content
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

Handling results from joins & identical column names #85

Closed
jordan0day opened this issue Dec 8, 2015 · 0 comments
Closed

Handling results from joins & identical column names #85

jordan0day opened this issue Dec 8, 2015 · 0 comments
Milestone

Comments

@jordan0day
Copy link
Contributor

If I perform a query like

SELECT people.id, people.name, pets.id, pets.name
FROM people
LEFT JOIN pets ON people.id = pets.person_id

I'll get a Mariaex.Result with a columns field of: ["id", "name", "id", "name"] and rows of `[[1, "Joe", 1, "Fluffy"], [1, "Joe", 2, "Fido"]].

This becomes really hard to deal with when the queries are more like

SELECT people.*, pets.*

When the query may return a different number of columns in the future.

Is there any way to have entries in the columns field include the table name? Or, alternatively, get results as a list of nested data structures?

For example, the npm mysql package handles this problem by including a nestTables option where you can either get results as a series of nested data structures, or specify a string for concatenating table name and column name: (https://www.npmjs.com/package/mysql#joins-with-overlapping-column-names).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants