sqlfluff / sqlfluff-online

An online SQL formatter, via SQLFluff.
https://online.sqlfluff.com/
34 stars 14 forks source link

Fix dialect selector #391

Closed nolanbconaway closed 2 months ago

nolanbconaway commented 2 months ago

fixes #389

I think there were changes introduced in https://github.com/sqlfluff/sqlfluff/pull/6153 which changed the behavior of sqlfluff.list_dialects via dialect_readout, in which each dialect object's name became the formatted name:

https://github.com/sqlfluff/sqlfluff/commit/2464d36c28a496012d6a2719b3c29483978e1407#diff-910b0d8394425a99e2c2a292887f1ac6a981341b51147a76cc7f1b79907ce933L89

This name gets passed directly to sqlfluff.api.lint/fix functions, which caused errors because those functions expect labels. So the site has effectively been down for a few weeks without me noticing!

This pr extends the dialects config variables such that we store a mapping of names to labels. Frontend users see only the names, which are mapped back to the label on the backend. HTTP get calls can use either the name or the label (mostly so that all the old tests continue to pass).

I added some tests that either can be used, and that the automatic dialect selector continues to work.