News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

[3204] SQLite does support REPLACE

Started by aldo, February 21, 2009, 05:27:50 PM

Previous topic - Next topic

aldo

I see in the Subs-Db-sqlite.php file in SMF 2.0, it mentions in smf_db_insert that SQLite does not support REPLACE, which isn't actually true.

I could see how this could be misunderstood by the way SQLite.org says so. According to the REPLACE page, it says it is an alias for the "INSERT OR REPLACE" variant...

So i checked it out, made an SQLite database and used this:

CREATE TABLE 'testing' (
  'id_group' INT,
  'permission' VARCHAR(60),
  'can' INT DEFAULT 1,
  PRIMARY KEY ('id_group','permission')
);

Now, if you query:

REPLACE INTO 'testing' VALUES(1, 'new_topic', 1);

Of course, you will get a new row added, which is no amazement of course. But now when you query:

REPLACE INTO 'testing' VALUES(1, 'new_topic', 0);

You still only have 1 row in that table, this is because of course the row is replaced :)

So if I am not mistaken, the SQLite Abstraction Layer shouldn't need any modification to make replace work. :)

EDIT: Sorry, should have said what version of SQLite... v2.8.17 ;)

karlbenson


karlbenson

We have moved this bug report to 2.1

At this stage in 2.0 we did not want to risk breaking anything since insert/replace is used throughout smf.

Advertisement: