Turn off auto backticks on autocomplete

613 views
Skip to first unread message

Frank

unread,
Feb 6, 2012, 1:23:07 PM2/6/12
to Sequel Pro
Hello All,

Is anyone aware of a way to turn off the auto backticks surrounding
words when auto completing table names?

Thanks!
Frank

Bob Siefkes

unread,
Feb 7, 2012, 2:47:23 AM2/7/12
to Sequel Pro
I noticed this behaviour myself and indeed agree that queries will be
less readable and more dfficult to maintain as either I want all with
backticks (I prefer not) or I want nothing with backticks. Would be
ideal if the auto backticks will only apply when needed.

I would then propose: No backtick when name only exists of
alphanumeric characters (e.g. 'title') or alphanumeric followed by
numeric (e.g. title2). However in case it's a resevered string then
backtick anyway (e.g. 'from', 'group' etc) The list of reserved words
is available.

For just running a query it's not a problem, but when copy/paste to
the application then it's nice to have consistent syntax.

Frank

unread,
Feb 7, 2012, 3:29:51 PM2/7/12
to Sequel Pro
Yeah this is actually the first editor I've encountered that forces
backticks on me. I understand how there might be users out there who
want this but please at least give me the option as I definitely think
it's less readable.

Jean-Yves

unread,
Mar 16, 2012, 5:18:36 AM3/16/12
to Sequel Pro
Personally I backtick everything for consistency, even though none of
my own field names are reserved words. This came about due to so many
of my clients having field names such as "name", "date", "count" etc.

I agree that it should be optional though, as I know that many people
don't like them. Just please don't remove the functionality
altogether!

Jakob Egger

unread,
Mar 16, 2012, 5:50:33 AM3/16/12
to seque...@googlegroups.com
Please DON'T make this an option in the preferences, just make the right choice and do what the user expects.

The solution is pretty straightforward:

1) If the user already typed a back tick, use back ticks in the completion
2) If the user did not type a back tick, do not use back ticks in the completion, except if back ticks are needed

It's trivial to check if back ticks are needed: Just see if the identifier matches the regular expression "[a-zA-Z][a-zA-Z0-9_]*", and check it against a list of keywords. Make sure you quote only those keywords where quotes are necessary. For example "SELECT name, date, text FROM events" is perfectly legal, no quotes necessary! See http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

If Sequel Pro would do it this way, it would just work for those who quote everything and those who quote only what's necessary.

Jakob


PS: If you don't believe me, just type this into the custom query window:
create temporary table events( name varchar(255), date date, text text)
MySQL requires a lot less quoting than Sequel Pro might make you think!


--
You received this message because you are subscribed to the Google Groups "Sequel Pro" group.
To post to this group, send email to seque...@googlegroups.com.
To unsubscribe from this group, send email to sequel-pro+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sequel-pro?hl=en.


Jean-Yves

unread,
Jun 22, 2012, 7:17:07 AM6/22/12
to seque...@googlegroups.com
Hi Jakob,

I like your solution about backticking only if a backtick is first input - that would indeed satisfy both us backtickers and the non-backtickers :-)

With regards your example of reserved words. I am aware that the SQL you show is legitimate, however my personal preference is still to backtick all table names, field names and aliases. I find that it avoids problems down the road, but I can understand why others might disagree.

BTW, are you the Jakob of MDBViewer fame?  If so, it's me Jean-Yves (aka Sparrowhawk). Small world :)


Reply all
Reply to author
Forward
0 new messages