[odb-users] Is running odb really a build-time task?

Per Edin info at peredin.com
Wed Mar 25 07:26:36 EDT 2015


Hi!

Is running odb really a build-time task? I know some tasks are, such
as running the Qt meta-object compiler. Qt moc generates code for
functionality which is similar to functionality already generated by
the C++ compiler, such as default constructors and destructors,
calling destructors, etc.

The odb compiler is quite different though, as it generates code that
is typically used directly by others parts of the program and this
code is tightly coupled to the C++ models. If an ORM had not been used
one would probably write the SQL mapping code first, then write code
that use it and finally attempt to build and test the whole thing. ODB
just automates the process of implementing the SQL mapping code and is
thus not a build-time task.

1. Implement models
2. Implement SQL-mapping code (or run odb)
3. Update business logic to use models and database CRUD functions
4. Build

My approach is now to run odb manually (using a script of course) once
I've made a change to my models, update the business logic if
necessary, and finally build. If everything worked, my model changes
and the odb output (source, sql and changelog) would be added to VCS.

This also removes the odb compiler from the list of requirements to
build my program.

To put this another way, all output of odb is (IMHO) supposed to be
version controlled and thus belongs in the source directory, the
output of Qt's moc is not and thus belongs in the build directory.

What are your thoughts on this?

/Per



More information about the odb-users mailing list