Shell tool allows creation of column name ""

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Shell tool allows creation of column name ""

Simon Slavin-3
Given a .csv file which starts like this:

ID,code,name,sortOrder,,AlternativeName
1,RAH,Robert A. Heinlein,"Heinlein, Robert A.",Real Name,
2,IA,Isaac Asimov,"Asimov, Isaac",Real Name,
3,HH,Harry Harrison,"Harrison, Harry",,

Shell tool of this version

SQLite version 3.19.3 2017-06-27 16:48:08

Creates a table with the following columns:

CREATE TABLE Authors(
  "ID" TEXT,
  "code" TEXT,
  "name" TEXT,
  "sortOrder" TEXT,
  "" TEXT,
  "AlternativeName" TEXT
);

I don’t know the externally-governed rules.  I don’t know what rules the development team want to follow.  But I’m questioning whether it’s a good idea to create a column with that name.  If the dev team think it’s okay, that’s fine with me.

I would actually prefer it didn’t include the quotes signs in the column names.  They’re not in the .csv file.  But that’s a different matter.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Shell tool allows creation of column name ""

Darren Duncan
I believe that as long as quoted identifiers are allowed, every value allowed as
a regular character string should also be allowed as an identifier, including
the empty string.  (Length limits notwithstanding.)

Some best practices may be against empty string names, but the system should
allow it.  Also serves as a good "default" name, like the good default character
string value would be empty or the good default number value would be zero.

I also believe that database tables with zero columns should be allowed, but
that's a separate matter.

-- Darren Duncan

On 2017-10-04 9:51 AM, Simon Slavin wrote:

> Given a .csv file which starts like this:
>
> ID,code,name,sortOrder,,AlternativeName
> 1,RAH,Robert A. Heinlein,"Heinlein, Robert A.",Real Name,
> 2,IA,Isaac Asimov,"Asimov, Isaac",Real Name,
> 3,HH,Harry Harrison,"Harrison, Harry",,
>
> Shell tool of this version
>
> SQLite version 3.19.3 2017-06-27 16:48:08
>
> Creates a table with the following columns:
>
> CREATE TABLE Authors(
>   "ID" TEXT,
>   "code" TEXT,
>   "name" TEXT,
>   "sortOrder" TEXT,
>   "" TEXT,
>   "AlternativeName" TEXT
> );
>
> I don’t know the externally-governed rules.  I don’t know what rules the development team want to follow.  But I’m questioning whether it’s a good idea to create a column with that name.  If the dev team think it’s okay, that’s fine with me.
>
> I would actually prefer it didn’t include the quotes signs in the column names.  They’re not in the .csv file.  But that’s a different matter.

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Shell tool allows creation of column name ""

David Raymond
In reply to this post by Simon Slavin-3
But without the quotes you couldn't have the empty string as a field name :) It also allows for spaces etc. and avoids needing logic to find out whether it really needs the quotes or not. And remember that the quotes aren't part of the field name, they're just there in the SQL text. In general though if it's "not a good idea to create a column with that name" then the user shouldn't have named the column that in their .csv file. The shell will at least give an error for duplicate column names if more than 1 column is named the empty string.

sqlite> pragma table_info(Authors);
cid,name,type,notnull,dflt_value,pk
0,ID,TEXT,0,,0
1,code,TEXT,0,,0
2,name,TEXT,0,,0
3,sortOrder,TEXT,0,,0
4,,TEXT,0,,0
5,AlternativeName,TEXT,0,,0

sqlite> select ID, code, name, sortOrder, AlternativeName from author;
ID          code        name                sortOrder            AlternativeName
----------  ----------  ------------------  -------------------  ---------------
1           RAH         Robert A. Heinlein  Heinlein, Robert A.
2           IA          Isaac Asimov        Asimov, Isaac
3           HH          Harry Harrison      Harrison, Harry

sqlite> select ID, "" from author;
ID
----------  ----------
1           Real Name
2           Real Name
3

Header line changed to: ID,code,name,,,AlternativeName
sqlite> .import authors.txt Authors2
CREATE TABLE Authors2(...) failed: duplicate column name:

sqlite>


-----Original Message-----
From: sqlite-users [mailto:[hidden email]] On Behalf Of Simon Slavin
Sent: Wednesday, October 04, 2017 12:51 PM
To: SQLite mailing list
Subject: [sqlite] Shell tool allows creation of column name ""

Given a .csv file which starts like this:

ID,code,name,sortOrder,,AlternativeName
1,RAH,Robert A. Heinlein,"Heinlein, Robert A.",Real Name,
2,IA,Isaac Asimov,"Asimov, Isaac",Real Name,
3,HH,Harry Harrison,"Harrison, Harry",,

Shell tool of this version

SQLite version 3.19.3 2017-06-27 16:48:08

Creates a table with the following columns:

CREATE TABLE Authors(
  "ID" TEXT,
  "code" TEXT,
  "name" TEXT,
  "sortOrder" TEXT,
  "" TEXT,
  "AlternativeName" TEXT
);

I don’t know the externally-governed rules.  I don’t know what rules the development team want to follow.  But I’m questioning whether it’s a good idea to create a column with that name.  If the dev team think it’s okay, that’s fine with me.

I would actually prefer it didn’t include the quotes signs in the column names.  They’re not in the .csv file.  But that’s a different matter.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users