Bug #70090 [Nab]: SQLite table with - in the name causes error when query
| From: | mike@php.net | Date: | Fri, 17 Jul 2015 07:21:20 +0000 |
| Subject: | Bug #70090 [Nab]: SQLite table with - in the name causes error when query | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194509@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70090&edit=1
ID: 70090
Updated by: mike@php.net
Reported by: david dot vantyghem at free dot fr
Summary: SQLite table with - in the name causes error when
query
Status: Not a bug
Type: Bug
Package: SQLite related
Operating System: Linux Mint MATE 17.2
PHP Version: 5.5Git-2015-07-17 (Git)
Block user comment: N
Private report: N
New Comment:
Yes, you need to quote the identifier because you use special characters in your identifier.
Previous Comments:
------------------------------------------------------------------------
[2015-07-17 07:07:04] david dot vantyghem at free dot fr
In this case, I don't think it's a problem of identifier or not. If I use a table without
-, it works with and without ' '.
If the name of the table contains -, it works only with ' '.
------------------------------------------------------------------------
[2015-07-17 07:03:07] yohgaki@php.net
https://www.sqlite.org/lang_keywords.html
I couldn't find good documents, but ANSI SQL needs "identifier-name" to make sure
identifier is treated as identifier.
------------------------------------------------------------------------
[2015-07-17 06:49:34] david dot vantyghem at free dot fr
Description:
------------
When a SQLite table contains - in its name, query sometimes show an error. The error disappears whit
adding ' ' at each side of the table name.
Test script:
---------------
With error :
$database_handle->query("SELECT * FROM software INNER JOIN software-compilations ON
software-compilations.compilation = ".$compilation_key." AND software.key =
software-compilations.software ORDER BY name");
Without error :
$database_handle->query("SELECT * FROM software INNER JOIN 'software-compilations'
ON 'software-compilations'.compilation = ".$compilation_key." AND software.key =
'software-compilations'.software ORDER BY name");
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70090&edit=1