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

Autodetect issues #30

Open
platima opened this issue Mar 12, 2024 · 8 comments
Open

Autodetect issues #30

platima opened this issue Mar 12, 2024 · 8 comments

Comments

@platima
Copy link
Contributor

platima commented Mar 12, 2024

Hey I've found a few issues with autodetect, and wondering if I am doing something wrong or if there are limitations I don't understand? Primarily, many many things autodetect as 'C'.

Eg
WITH employee_ranking AS ( SELECT employee_id, last_name, RANK() OVER (ORDER BY salary DESC) as ranking FROM employee ) SELECT employee_id, last_name, FROM employee_ranking WHERE ranking <= 5 ORDER BY ranking

I'd expect to very clearly be SQL, and then
<meta property="og:description" content="One of the best ways to learn advanced SQL is by reading examples of queries. Check 25 advanced queries that will help you build your SQL skills." /> <meta property="og:type" content="article" /> <meta property="og:url" content="https://learnsql.com/blog/25-advanced-sql-query-examples/" /><meta property="article:published_time" content="2023-02-28T18:00:00&#43;02:00"/> <meta property="article:modified_time" content="2023-02-28T18:00:00&#43;02:00"/><meta property="og:site_name" content="LearnSQL.com" /> <meta property="article:publisher" content="https://www.facebook.com/groups/welearnsql/" /> <meta property="article:section" content="blog" /> <meta property="article:tag" content="sql" /> <meta property="article:tag" content="learn sql" /> <meta property="article:tag" content="online practice" /> <meta property="article:tag" content="advanced sql" />
is quite clearly HTML.

Both auto-detect as 'C' though. Tested with a few releases, same result. Putting at the start obviously works, but is not always how it'll be used.

Any ideas?

@ctapmex
Copy link
Member

ctapmex commented Mar 12, 2024

Hi.
You're using colorer.exe ? which version or source build (commit)?
the type definition is influenced by both the file name and the first lines - which name is used?

@platima
Copy link
Contributor Author

platima commented Mar 12, 2024

Hey latest build, linux x64, and reading from stdin.

@ctapmex
Copy link
Member

ctapmex commented Mar 12, 2024

Auto-detection works on the file name and the first lines of the file. To do this, the prototype description must specify the appropriate regular expressions for them. If you look at proto.hrc, then there are no regular expressions for the first lines for the "database" group.
and since we use stdin, there is no file name for analysis either. For this reason, auto-detection takes the first file type in the list - others cannot defeat it.
Can you suggest regular expressions that would be suitable for the first lines of an arbitrary sql file?

@platima
Copy link
Contributor Author

platima commented Mar 12, 2024

Ah roger that. I'll come up with some regex for a few and issue a PR

@platima
Copy link
Contributor Author

platima commented Mar 13, 2024

@ctapmex
Copy link
Member

ctapmex commented Mar 22, 2024

I'll roll out all the changes for now. Even the changes that remained broke the tests. In the meantime, there is no time to figure it out.
If you are interested to see what kind of tests, then https://github.com/colorer/Colorer-schemes/blob/master/README.md#develop

@platima
Copy link
Contributor Author

platima commented Mar 22, 2024

Ah excellent, thanks!

@platima
Copy link
Contributor Author

platima commented Mar 22, 2024

(FYI I did not update changelog sorry, might want to!)

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

No branches or pull requests

2 participants