4 ms·
I see your point, but FROM-first SQL would provide better support for autocomplete. Right now in e.g. psql when you write "SELECT " and press <Tab>, it can't h
by ainar-g 7y ago
I see your point, but FROM-first SQL would provide better support for
autocomplete. Right now in e.g. psql when you write "SELECT " and press
<Tab>, it can't help you with the columns. But if you could write "FROM
users SELECT " and then press <Tab>, then the DB client could tell that
you probably want a column of the "users" table.
- jfim 7y agoYou can use the WITH clause if you prefer that style. WITH employee AS (SELECT * FROM EMPLOYEES), department AS (SELECT * FROM DEPARTMENTS) SELECT employee.name, department.name FROM employee INNER JOIN department ON employee.department_id = department.department_id
- clhodapp 7y agoHow does that help at all, though? When it comes time to write the final select, you still haven't established the meanings of the things you are selecting from until you write the from and join clauses.
- jfim 7y agoYour IDE should be able to complete the columns at that point, so when it comes to typing SELECT employee.name, the IDE knows that name is a column of the EMPLOYEES table. This works with IntelliJ and Datagrip, I don't know about other IDEs.
- clhodapp 7y agoIt shouldn't, though, because there is no table bound to that name to draw from at that point. You haven't added a from-list that is actually relevant to the current scope yet.
- jfim 7y agoIt does work as described, with column type information and field suggestions, on IntelliJ 2019.2 and Datagrip 2019.2.
- clhodapp 7y agoI totally believe that it gives the suggestions as you describe, what I'm saying is that in order for it do that, the completion must be making faulty assumptions about the way that scoping works in SQL.
- deleted 7y ago[deleted]