kvasilov48 / firephp

Automatically exported from code.google.com/p/firephp
0 stars 0 forks source link

Renderer for SQL queries #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The renderer should parse the SQL statement and display it formatted and
color coded. There should also be an option to view the "raw" query.

Does anyone know of an open-source javascript library to parse an SQL query
and present it formatted?

Original issue reported on code.google.com by christ...@christophdorn.com on 15 Oct 2008 at 12:59

GoogleCodeExporter commented 9 years ago
How do you want it formatted? In Html with classes or styles?
I'll have a go at this if there isn't a solution already there.

Original comment by jaap.t...@gmail.com on 15 Oct 2008 at 12:54

GoogleCodeExporter commented 9 years ago
A possible route to a solution:
http://jscc.jmksf.com (LALR(1)) javascript parser generator
http://savage.net.au/SQL/ BNF grammers for sql

The grammar instructions could either return html code or build a dom document
fragment...

Original comment by jaap.t...@gmail.com on 15 Oct 2008 at 1:04

GoogleCodeExporter commented 9 years ago
this approach would be slow and large, but correct (if it al works)

Original comment by jaap.t...@gmail.com on 15 Oct 2008 at 1:10

GoogleCodeExporter commented 9 years ago
I like the idea of implementing this properly rather than as a quick fix but as 
you
mentioned it could become quite the undertaking.

The result should ideally integrate with domplate but that may be very 
complicated to
accomplish right off the bat. The best approach may be to generate a tree 
containing
the different elements and hints to indicate the type of each element.

We can then write a renderer that uses the tree to generate a HTML 
representation
directly or one that integrates with domplate.

Before you start on this it may be worth while to do a bit more research to 
ensure
there is not something already out there or more suitable as a base. Maybe we 
could
use a code editor/colorer as the base instead
(http://marijn.haverbeke.nl/codemirror/)? I am looking for a PHP code 
viewer/editor
as well and I have been looking at codemirror to accomplish this.

Original comment by christ...@christophdorn.com on 15 Oct 2008 at 8:06

GoogleCodeExporter commented 9 years ago
I agree, we'll need to investigate whether codemirror can be "stripped" down 
easiliy.
Disadvantage of Codemirror is that it's parsers are hand written. It is however 
a
very active project and I think Marijn will be able to help out (I'm also 
Dutch).
I'll ask him to respond to this issue.

Original comment by jaap.t...@gmail.com on 15 Oct 2008 at 10:58

GoogleCodeExporter commented 9 years ago
Yes. I like that the project seems active. Maybe you could ask him about his 
future
plans and commitment to codemirror.

My plans are to make FirePHP and more importantly the overall concept of 
debugging
AJAX and server apps this way a household name so I am looking to incorporate 
code
that will stay maintained.

Original comment by christ...@christophdorn.com on 15 Oct 2008 at 11:08

GoogleCodeExporter commented 9 years ago
Addinitional features requested by co-workers (they are to lazy to reply 
themselves):
SQL: folding of clauses
But you probably already had that in mind
Folding might also be useful for PHP code.

I'd say creating a SQL parser shouldn't be to difficult given the existing 
SPARQL parser.

Original comment by jaap.t...@gmail.com on 15 Oct 2008 at 11:12

GoogleCodeExporter commented 9 years ago
Hi. I'm the author of CodeMirror. If you just want something to *display* 
highlighted
code, it's bound to be easier to just write something from scratch. A lot of
CodeMirror's complexity is related to the fact that it's an editor, and has to 
do the
parsing incrementally while the text is being edited. As for commitment, I'm not
planning to stop fixing bugs anytime soon, but since this is all unpaid, I 
can't make
any guarantees -- I don't always have a lot of time.

Original comment by mari...@gmail.com on 16 Oct 2008 at 8:08

GoogleCodeExporter commented 9 years ago
Displaying the highlighted SQL would be the first step but I see a few other 
features
over time:

1) Have the renderer automatically format and indent an SQL query for easier 
reading.
Would be great if the user could setup a "profile" on how to indent the query 
and
have the renderer follow that profile for all subsequent queries.

2) Ability to render partial and invalid queries to allow easier debugging and 
fixing
of queries

3) Ability to edit queries in FirePHP and save modifications back to server code

I am planning on making FirePHP two-way allowing you to edit your server code in
FirePHP and saving it back to the server. So the above requirements also apply 
to
PHP, CSS, HTML, XML, JSON, etc... code. I would be looking for an editor that 
can
accomplish highlighting and editing of all these languages.

Do you think CodeMirror could accomplish this?

Original comment by christ...@christophdorn.com on 16 Oct 2008 at 7:04

GoogleCodeExporter commented 9 years ago
@christoph:
Did you check out
http://codepress.sourceforge.net/
yet?

Codepress allready has PHP and SQL implemented according to
http://en.wikipedia.org/wiki/Comparison_of_Javascript-based_source_code_editors

No offence Marijn!

Original comment by jaap.t...@gmail.com on 16 Oct 2008 at 8:18

GoogleCodeExporter commented 9 years ago
Yes I had some time ago, but there has been very little development activity 
for a
while so I am not too sure about the state of the project.

Thanks for the link to the matrix!

What do you think of EditArea?

Original comment by christ...@christophdorn.com on 16 Oct 2008 at 8:51

GoogleCodeExporter commented 9 years ago
Anyone interested in starting a project to port GeSHi 
(http://qbnz.com/highlighter/)
to JavaScript and adding an editor component?

Original comment by christ...@christophdorn.com on 17 Oct 2008 at 12:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Google code itself (you know, this site) uses a JavaScript called prettify.

http://code.google.com/p/google-code-prettify/

Includes SQL per the FAQ.

Original comment by sroussey on 28 Apr 2009 at 12:20

GoogleCodeExporter commented 9 years ago
I don't think this lib meets the necessary requirements. We need something that
breaks the SQL into its parts and colors each part appropriately with the 
ability to
format it as well.

Original comment by christ...@christophdorn.com on 28 Apr 2009 at 3:44

GoogleCodeExporter commented 9 years ago
What about http://alexgorbatchev.com/wiki/SyntaxHighlighter:Brushes:SQL instead 
of GeSHi

Original comment by sander.w...@gmail.com on 12 May 2009 at 9:42

GoogleCodeExporter commented 9 years ago
Looks like a better fit. No formatting but that could be added later if really
necessary. I wonder how this lib works with complex SQL queries.

Original comment by christ...@christophdorn.com on 13 May 2009 at 1:01

GoogleCodeExporter commented 9 years ago
Here you can see a sample of the highlighter:
http://www.sawey.be/sql-highlight/

Original comment by sander.w...@gmail.com on 14 May 2009 at 8:17

GoogleCodeExporter commented 9 years ago
Looks like it can handle most of the syntax. Function highlighting does not 
seem to
work in all cases.

Looking at the formatting and highlighting it should be possible to add
auto-formatting support if all the nested brackets are properly parsed as well.

Original comment by christ...@christophdorn.com on 14 May 2009 at 8:49