unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>,
	Thomas Hilke <t.hilke@rollomatic.ch>,
	Lars Ingebrigtsen <larsi@gnus.org>
Cc: 65998@debbugs.gnu.org
Subject: bug#65998: Sqlite-mode issue deleting records and closing database
Date: Sat, 16 Sep 2023 07:07:51 -0700	[thread overview]
Message-ID: <CADwFkmk=Wfs9=rnvLRdGHVo1g_5tnnmvcfwqjiQofe4gXvbKgA@mail.gmail.com> (raw)
In-Reply-To: <83h6nuiffv.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> writes:

>> - The sql query built by sqlite-mode-delete is syntactically correct,
>>   but misinterpreted by sqlite, and eventually do nothing. The query
>>   is of the form "REMOVE FROM table_name WHERE rowid = ? and
>>   'column_name_1' = ? and 'column_name_2' = ? and ..."  From
>>   https://www.sqlite.org/lang_keywords.html, if I understand
>>   correctly, the quoted column names in the WHERE clause are
>>   interpreted as strings from sqlite, and as a result not a single row
>>   is ever matched and deleted.
>
> Thanks.  I installed on the emacs-29 branch the first part of your
> patch, which closes the DB when the buffer is killed.  As for the
> second part, I'd prefer that Lars or someone who knows SQL reviewed it
> first, as I find it strange that Lars would code something so basic
> which doesn't work at all.
>
> Could someone who knows SQL please review and chime in?

Something like this in an SQL "REMOVE FROM table_name WHERE {foo}" clause

    'column_name_1' = ?

will check if the '?' part is equal to the string 'column_name_1', which
is probably not what we want.

Whereas this

    column_name_1 = ?

will instead check if the '?' part is equal to the value of the column
column_name_1 in table_name.

(The "?" is just a placeholder that will be filled in with an actual
value later.)

So without having tested the code or studied it in detail, the analysis
of the problem sounds right to me.

Don't we have unit tests in place for this stuff, though?  Perhaps we
should see this as an opportunity to add some...





  reply	other threads:[~2023-09-16 14:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15  9:02 bug#65998: Sqlite-mode issue deleting records and closing database Thomas Hilke via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-16 10:24 ` Eli Zaretskii
2023-09-16 14:07   ` Stefan Kangas [this message]
2023-09-17 10:05     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmk=Wfs9=rnvLRdGHVo1g_5tnnmvcfwqjiQofe4gXvbKgA@mail.gmail.com' \
    --to=stefankangas@gmail.com \
    --cc=65998@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    --cc=t.hilke@rollomatic.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).