Re: [sqlite] Column names including spaces

2012-02-23 Thread Stephan Beal
On Wed, Feb 22, 2012 at 11:14 PM, Petite Abeille
petite.abei...@gmail.comwrote:

 http://www.sqlite.org/lang_keywords.html


@sqlite3 committers: there's a minor error on that page: is says There are
three ways of quoting... and then goes on to show four ways.

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Column names including spaces

2012-02-22 Thread Pete
I seem to have stumbled upon what looks like a bug in SQLite.  I
accidentally created a column in a table that included a space in its
name,eg Col 1.  The CREATE TABLE command accepted without an error but if
I try to access that column in any way, I get an error, no matter whether I
specify the column name with no quotes, single quotes or double quotes.
 For example if I SELECT Col 1 FROM... I get a syntax error near 1
(which I'd expect).  If I try 'SELECT CoL 1 FROM..., I get and error no
such column Col1 - notice there is no space in the column name listed in
the error message.

I'm not unduly concerned since this column name should never have had a
space in it in the first place but perhaps CREATE TABLE should flag an
error in this situation if the column can't be accessed?


-- 
Pete
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Column names including spaces

2012-02-22 Thread Stephan Beal
On Wed, Feb 22, 2012 at 10:21 PM, Pete p...@mollysrevenge.com wrote:

 I seem to have stumbled upon what looks like a bug in SQLite.  I
 accidentally created a column in a table that included a space in its
 name,eg Col 1.  The CREATE TABLE command accepted without an error but if
 I try to access that column in any way, I get an error, no matter whether I
 specify the column name with no quotes, single quotes or double quotes.
 ...


stephan@tiny:~$ sqlite3
SQLite version 3.7.7 2011-06-23 19:49:22
Enter .help for instructions
Enter SQL statements terminated with a ;
sqlite create table t([Col 1]);
sqlite .h on
sqlite insert into t values('a');
sqlite select * from t;
Col 1
a
sqlite select [Col 1] from t;
Col 1
a

Hope that helps,

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Column names including spaces

2012-02-22 Thread Igor Tandetnik

On 2/22/2012 4:21 PM, Pete wrote:

I seem to have stumbled upon what looks like a bug in SQLite.  I
accidentally created a column in a table that included a space in its
name,eg Col 1.  The CREATE TABLE command accepted without an error but if
I try to access that column in any way, I get an error, no matter whether I
specify the column name with no quotes, single quotes or double quotes.
  For example if I SELECT Col 1 FROM... I get a syntax error near 1
(which I'd expect).  If I try 'SELECT CoL 1 FROM..., I get and error no
such column Col1 - notice there is no space in the column name listed in
the error message.


Must be a problem with a tool or wrapper you use. Column names enclosed 
in double quotes do work in SQLite.

--
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Column names including spaces

2012-02-22 Thread John Drescher
  For example if I SELECT Col 1 FROM... I get a syntax error near 1
 (which I'd expect).  If I try 'SELECT CoL 1 FROM..., I get and error no
 such column Col1 - notice there is no space in the column name listed in
 the error message.


Are you escaping the quotes for whatever language / tool you are using
so they are passed to SQLITE?

John
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Column names including spaces

2012-02-22 Thread Petite Abeille

On Feb 22, 2012, at 10:21 PM, Pete wrote:

 I try to access that column in any way, I get an error, no matter whether I
 specify the column name with no quotes, single quotes or double quotes

For the record:

http://www.sqlite.org/lang_keywords.html

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users