Comments on: SQL Emulation Tool in Javascript Part 2 http://www.terminally-incoherent.com/blog/2009/05/19/sql-emulation-tool-in-javascript-part-2/ I will not fix your computer. Tue, 04 Aug 2020 22:34:33 +0000 hourly 1 https://wordpress.org/?v=4.7.26 By: Adam Kahtava http://www.terminally-incoherent.com/blog/2009/05/19/sql-emulation-tool-in-javascript-part-2/#comment-12493 Sun, 07 Jun 2009 18:07:50 +0000 http://www.terminally-incoherent.com/blog/?p=3083#comment-12493

Cool potatoes… Have you consider name spacing your JS or binding your variables to a local context. How about http://www.jslint.com :) I’m being picky, but after a month of refactoring other developers JS I can’t turn off my JS gotcha eyes.

Reply  |  Quote
]]>
By: Luke Maciak http://www.terminally-incoherent.com/blog/2009/05/19/sql-emulation-tool-in-javascript-part-2/#comment-12362 Thu, 21 May 2009 01:59:45 +0000 http://www.terminally-incoherent.com/blog/?p=3083#comment-12362

@Chris Wellons: Yeah, sorry about the DOS newlines. I shall apply this to the code, and reposition the text box. :)

Reply  |  Quote
]]>
By: Chris Wellons http://www.terminally-incoherent.com/blog/2009/05/19/sql-emulation-tool-in-javascript-part-2/#comment-12361 Wed, 20 May 2009 22:47:08 +0000 http://www.terminally-incoherent.com/blog/?p=3083#comment-12361

Allow multiple spaces in a query,


diff --git a/sql.js b/sql.js
index 207848b..1969796 100644
--- a/sql.js
+++ b/sql.js
@@ -67,9 +67,7 @@ parser.sanitize = function(sql) {
.strip()
.stripTags()
.stripScripts()
- .gsub("\r", "")
- .gsub("\n", " ")
- .gsub("\t", "")
+ .gsub(/\s+/, " ")
.str
}

Doesn’t take into account spaces inside quotes, but neither did the stuff I deleted. :-P And DOS newlines! For shame! That messed me up doing my diff.

On the demo page, it’s annoying having the textarea position change depending on query results. I would put it at the top so it sits still.

Reply  |  Quote
]]>
By: TCP http://www.terminally-incoherent.com/blog/2009/05/19/sql-emulation-tool-in-javascript-part-2/#comment-12357 Wed, 20 May 2009 06:28:29 +0000 http://www.terminally-incoherent.com/blog/?p=3083#comment-12357

very cool & good script, thank you very much for sharing.

Can I share this script on my JavaScript library, http://javascriptbank.com/submit/ ?

Thank

Reply  |  Quote
]]>