inkytonik / cooma

The Cooma project is investigating secure programming language design based on fine-grained object capabilities.
Mozilla Public License 2.0
3 stars 2 forks source link

Database mutations #62

Closed nhweston closed 2 years ago

nhweston commented 2 years ago

This PR:

New methods

A new method is introduced to retrieve a single row by its primary key. Methods are also added for insertion, update, and deletion.

These methods require rows to be identified by their primary key. There is now a requirement that all tables have a column named id, and that this column be a primary key, non-nullable, and of integer type. See #21 for further discussion.

The mutations (insert, update, and delete) return Either(DbError, Int). If the mutation succeeds, a Right is returned with the number of rows affected. If an error occurs, a Left is returned containing the error code and a message.

The new methods are:

Refactoring

There are several forms of data involved in the database capability that need to be converted between each other:

The Metadata, DbType, and DbValue classes serve as intermediate representations of databases, types, and values (respectively), with methods provided to convert to and from these different forms.

inkytonik commented 2 years ago

Looks great to me, particularly the level of testing. It's a great addition to Cooma. Feel free to merge.