Skip to content

Commit

Permalink
Fixed an issue in the SQL parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Laborie committed Mar 27, 2012
1 parent 185efee commit 01dd168
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
36 changes: 32 additions & 4 deletions Resources/dump_movie.sql
@@ -1,12 +1,34 @@
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE movies(id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, rating INTEGER);

------------
-- MOVIES --
------------

-- TABLE movies
-- This table contains a lit of movies.
CREATE TABLE movies(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT,
rating INTEGER);

-- Insert some movies.
INSERT INTO "movies" VALUES(1,'The Shawshank Redemption',9.2);
INSERT INTO "movies" VALUES(2,'The Godfather',9.2);
INSERT INTO "movies" VALUES(3,'The Godfather: Part II',9);
INSERT INTO "movies" VALUES(4,'The Good, the Bad and the Ugly',8.9);
INSERT INTO "movies" VALUES(5,'Pulp Fiction',8.9);
CREATE TABLE actors(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT);

------------
-- ACTORS --
------------

-- TABLE actors
-- This table contains a lit of actors.
CREATE TABLE actors(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT);

-- Insert some actors.
INSERT INTO "actors" VALUES(1,'Morgan Freeman');
INSERT INTO "actors" VALUES(2,'Tim Robbins');
INSERT INTO "actors" VALUES(3,'Marlon Brando');
Expand All @@ -16,6 +38,13 @@ INSERT INTO "actors" VALUES(6,'Eli Wallach');
INSERT INTO "actors" VALUES(7,'Clint Eastwood');
INSERT INTO "actors" VALUES(8,'John Travolta');
INSERT INTO "actors" VALUES(9,'Samuel L. Jackson');

---------
-- ACT --
---------

-- TABLE act
-- This table makes the link between the actors and the movies.
CREATE TABLE act(movie_id INTEGER, actor_id INTEGER);
INSERT INTO "act" VALUES(1,1);
INSERT INTO "act" VALUES(1,2);
Expand All @@ -27,4 +56,3 @@ INSERT INTO "act" VALUES(4,6);
INSERT INTO "act" VALUES(4,7);
INSERT INTO "act" VALUES(5,8);
INSERT INTO "act" VALUES(5,9);
COMMIT;
2 changes: 1 addition & 1 deletion Resources/dump_short_comment.sql
Expand Up @@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT
/**
Multi-line comment
*/
INSERT INTO users(name) VALUES(Bob);
/** ---- * - * */INSERT INTO users(name) VALUES(Bob);
INSERT INTO users(name) VALUES(ボブ);
INSERT INTO users(name) VALUES(ผมบ๊อบ);

6 changes: 3 additions & 3 deletions SQLiteKit/SQLFile.m
Expand Up @@ -161,7 +161,7 @@ unsigned int getNextLine(FILE *stream, buffer_t streamBuffer, buffer_t lineBuffe
{
case '*':
{
if ( previousChar == '/' && inhibitor == 0 )
if ( inhibitor == 0 && previousChar == '/' )
{
lineBuffer->length--;
inhibitor = currentChar;
Expand All @@ -171,7 +171,7 @@ unsigned int getNextLine(FILE *stream, buffer_t streamBuffer, buffer_t lineBuffe
}
case '/':
{
if ( previousChar == '*' && inhibitor == '*' )
if ( inhibitor == '*' && previousChar == '*' )
{
inhibitor = 0;
shouldCopy = true;
Expand All @@ -182,7 +182,7 @@ unsigned int getNextLine(FILE *stream, buffer_t streamBuffer, buffer_t lineBuffe
}
case '-':
{
if ( previousChar == '-' )
if ( inhibitor == 0 && previousChar == '-' )
{
lineBuffer->length--;
inhibitor = '\n';
Expand Down

0 comments on commit 01dd168

Please sign in to comment.