Skip to content

Synchronized internal naming scheme + bug fixes

Compare
Choose a tag to compare
@marcgrue marcgrue released this 07 Mar 13:44
· 422 commits to master since this release

In order to synchronize scala molecule boilerplate code and its internal representation,
namespace names are now capitalized also in molecule model/query/datalog. This
applies when no custom partitions are defined (and namespaces not partition-prefixed):

// Namespace names are now capitalized in the model
m(Community.name)._model === Model(List(
  Atom("Community", "name", "String", 1, VarValue) // "Community" now uppercase
))

// Uppercase namespace names are also retrieved when querying the schema
Schema.a.part.ns.nsFull.attr.get === List((
  ":Community/name", // namespace name now uppercase 
  "db.part/user", // default partition (not prefixed to namespaces)
  "Community", // now uppercase
  "Community", // now uppercase (has no partition prefix when no custom partition is defined)
  "name"
))

// Produced Datalog queries will also use the uppercase namespace name 
[:find  ?b
 :where [?a :Community/name ?b]]

This change takes away the need to lower/capitalize namespace names back and forth
between the source code representation and molecule model/query/datalog representations.
It also makes it easier to distinguish between namespace/attribute names in internal
molecule representations.

Unaffected with custom partitions

As before, custom partition-prefixed namespaces are unaffected:

// Namespace names are now capitalized in the model
m(accounting_Invoice.invoiceLine)._model === Model(List(
  Atom("accounting_Invoice", "invoiceLine", "ref", 1, VarValue)
))

// Querying the schema
Schema.a.part.ns.nsFull.attr.get === List((
  ":accounting_Invoice/invoiceLine", 
  "accounting", // custom partition (always lowercase)
  "Invoice", // namespace now uppercase
  "accounting_Invoice", // partition-prefixed namespace
  "invoiceLine"
))

// Datalog query 
[:find  ?b
 :where [?a :accounting_Invoice/invoiceLine ?b]]

Working with non-molecule Datomic databases

For the end user internal uppercase namespace names have no impact unless you are working
with externally defined Datomic databases or data sets that can have lowercase namespace
names defined.

The sbt-plugin (as of version 0.8) now generates two additional schema transaction files
that can be transacted with the external lowercase database so that you can use your
uppercase Molecule code with it:

Molecule schema (uppercase) + external data (lowercase)

When importing external data
(example)
from a database with lowercase namespace names then you can
transact lowercase attribute aliases
(example)
so that your uppercase Molecule code can recognize the
imported lowercase data:

conn.datomicConn.transact(SchemaUpperToLower.namespaces)

External schema (lowercase) + external data (lowercase)

If both external schema and data is created with lowercase namespace names, then you can transact
uppercase attribute aliases with the live database so that it will recognize your uppercase
molecule code
(example):

conn.datomicConn.transact(MBrainzSchemaLowerToUpper.namespaces)