[odb-users] Index Pragmas DO NOT support index on expressions

Reilly He reillyhekazusa at gmail.com
Fri Feb 17 07:22:37 EST 2023


Ok, thanks for the clarification.

On Fri, Feb 17, 2023 at 6:20 PM Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Reilly He <reillyhekazusa at gmail.com> writes:
>
> > > So there is still a possibility of, say, renaming the id member but
> > > forgetting to update the index definition.
> > >
> >
> > I got to say I am a little bit confused about this statement, since I
> take
> > a look at the docs of SQLite Alter Table
> > <https://www.sqlite.org/lang_altertable.html>, and here I quote:
> >
> > > The RENAME COLUMN TO syntax changes the column-name of table table-name
> > > into new-column-name. The column name is changed both within the table
> > > definition itself *and also within all indexes*, triggers, and views
> that
> > > reference the column. If the column name change would result in a
> semantic
> > > ambiguity in a trigger or view, then the RENAME COLUMN fails with an
> error
> > > and no changes are applied.
> >
> > Actually I`ve done my experiment today, and the saying of SQLite was
> *TRUE*,
> > so things like changing the column name actually will not fail any index
> > including the changed column.
> >
> > but according to your statement, are you saying that if we already add an
> > index using ODB`s index pragma, and we somehow *changed the member name*
> > (column name), the compiling process of ODB will *fail*?
>
> No, it's in a sense the opposite: if you use raw column names and there
> is a mismatch, then the ODB compiler is not going to fail and you will
> likely get a runtime error later.
>
> In the example I've given SQLite is smart enough to take care of things
> if you are changing the schema. But you could also be creating the
> schema (with mismatched column/index) from scratch, say, in a new
> database. In this case I am pretty certain you will get a runtime
> error since the index will refer to the column that does not exist.
>


More information about the odb-users mailing list