4 ms·
I wanted to use this linter, but they don't support many things that are used in real production code. By example, a simple postgres function like this one can'
by ErunamoJAZZ 5y ago
I wanted to use this linter, but they don't support many things that are used in real production code.
By example, a simple postgres function like this one can't be parsed:
CREATE OR REPLACE FUNCTION public.setof_test()
RETURNS SETOF text
LANGUAGE sql
STABLE STRICT
AS $function$
select unnest(array['hi', 'test'])
$function$
;
- munro 5y agoThe code looks really great [1], very declarative, looks like it should be pretty easy to add better PostgreSQL support. I also wonder if how easy it would be to plug it into VS Code, and build in an auto formatter (♥ω♥ ). At a glance it looks like it's parsing AST, which is really hard to find for SQL, so auto formatter could be possible to build from this. I notice SQLite could use some improving too, seems like a great project to coalesce around. [1] https://github.com/sqlfluff/sqlfluff/blob/main/src/sqlfluff/dialects/dialect_postgres.py https://github.com/sqlfluff/sqlfluff/blob/main/src/sqlfluff/...
- amshank 5y agoAuto-formatter is already built in for some simple violations: https://docs.sqlfluff.com/en/stable/cli.html#sqlfluff-fix https://docs.sqlfluff.com/en/stable/cli.html#sqlfluff-fix
- tunetheweb 5y agoThere already is a VS Code extension for this: https://marketplace.visualstudio.com/items?itemName=dorzey.vscode-sqlfluff https://marketplace.visualstudio.com/items?itemName=dorzey.v... https://github.com/sqlfluff/vscode-sqlfluff https://github.com/sqlfluff/vscode-sqlfluff
- munk-a 5y agoI really personally dislike how you fail to shout the keywords in the above function "that actually matter" - all the set dressing and obvious stuff is capitalized - but then the meat of the function is all in lowercase hiding in the middle.
- tunetheweb 5y agoLooks like we didn't support SETOF. Added this here: https://github.com/sqlfluff/sqlfluff/pull/1522 https://github.com/sqlfluff/sqlfluff/pull/1522 Demonstrating how easy it is to add this sort of thing to the project thanks to how the code is structured! :-)