aboutsummaryrefslogtreecommitdiff
path: root/libbrep
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-12-09 15:47:34 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-12-09 15:47:34 +0300
commitd259750511b3c2aaeace49f8ccb1d7f3ad561452 (patch)
tree9a98e1a2a66fc8a25dc1b58efd2e7e0e77201914 /libbrep
parent4bc9390c48cee736917ead5d20aa216fe10bae47 (diff)
Prepare for supporting multiple ids in requirement alternative
Diffstat (limited to 'libbrep')
-rw-r--r--libbrep/build-extra.sql17
-rw-r--r--libbrep/build-package.hxx28
-rw-r--r--libbrep/build.hxx2
-rw-r--r--libbrep/build.xml2
-rw-r--r--libbrep/common.hxx19
-rw-r--r--libbrep/package.hxx25
-rw-r--r--libbrep/package.xml46
7 files changed, 131 insertions, 8 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql
index bd3df2b..a8464cf 100644
--- a/libbrep/build-extra.sql
+++ b/libbrep/build-extra.sql
@@ -12,6 +12,8 @@ DROP FOREIGN TABLE IF EXISTS build_package_builds;
DROP FOREIGN TABLE IF EXISTS build_package_tests;
+DROP FOREIGN TABLE IF EXISTS build_package_requirement_alternative_requirements;
+
DROP FOREIGN TABLE IF EXISTS build_package_requirement_alternatives;
DROP FOREIGN TABLE IF EXISTS build_package_requirements;
@@ -82,9 +84,22 @@ CREATE FOREIGN TABLE build_package_requirement_alternatives (
version_revision INTEGER NOT NULL,
requirement_index BIGINT NOT NULL,
index BIGINT NOT NULL,
- id TEXT NOT NULL)
+ enable TEXT NULL)
SERVER package_server OPTIONS (table_name 'package_requirement_alternatives');
+CREATE FOREIGN TABLE build_package_requirement_alternative_requirements (
+ tenant TEXT NOT NULL,
+ name CITEXT NOT NULL,
+ version_epoch INTEGER NOT NULL,
+ version_canonical_upstream TEXT NOT NULL,
+ version_canonical_release TEXT NOT NULL COLLATE "C",
+ version_revision INTEGER NOT NULL,
+ requirement_index BIGINT NOT NULL,
+ alternative_index BIGINT NOT NULL,
+ index BIGINT NOT NULL,
+ id TEXT NOT NULL)
+SERVER package_server OPTIONS (table_name 'package_requirement_alternative_requirements');
+
-- The foreign table for the build_package object tests member (that is of a
-- container type).
--
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 77520d1..c46119d 100644
--- a/libbrep/build-package.hxx
+++ b/libbrep/build-package.hxx
@@ -135,17 +135,41 @@ namespace brep
// requirements
//
- #pragma db member(requirement_key::outer) column("requirement_index")
- #pragma db member(requirement_key::inner) column("index")
+ // Note that this is a 2-level nested container (see package.hxx for
+ // details).
+ //
+ // Container of the requirement_alternatives values.
+ //
#pragma db member(requirements) id_column("") value_column("")
+
+ // Container of the requirement_alternative values.
+ //
+ #pragma db member(requirement_alternative_key::outer) column("requirement_index")
+ #pragma db member(requirement_alternative_key::inner) column("index")
+
#pragma db member(requirement_alternatives) \
virtual(requirement_alternatives_map) \
after(requirements) \
get(odb::nested_get (this.requirements)) \
set(odb::nested_set (this.requirements, std::move (?))) \
+ id_column("") key_column("") value_column("")
+
+ // Container of the requirement (string) values.
+ //
+ #pragma db member(requirement_key::outer) column("requirement_index")
+ #pragma db member(requirement_key::middle) column("alternative_index")
+ #pragma db member(requirement_key::inner) column("index")
+
+ #pragma db member(requirement_alternative_requirements) \
+ virtual(requirement_alternative_requirements_map) \
+ after(requirement_alternatives) \
+ get(odb::nested2_get (this.requirements)) \
+ set(odb::nested2_set (this.requirements, std::move (?))) \
id_column("") key_column("") value_column("id")
+ // tests, builds, and constraints
+ //
#pragma db member(tests) id_column("") value_column("test_")
#pragma db member(builds) id_column("") value_column("")
#pragma db member(constraints) id_column("") value_column("")
diff --git a/libbrep/build.hxx b/libbrep/build.hxx
index 29d9890..de12a70 100644
--- a/libbrep/build.hxx
+++ b/libbrep/build.hxx
@@ -30,7 +30,7 @@
//
#define LIBBREP_BUILD_SCHEMA_VERSION_BASE 15
-#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 15, closed)
+#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 16, closed)
// We have to keep these mappings at the global scope instead of inside
// the brep namespace because they need to be also effective in the
diff --git a/libbrep/build.xml b/libbrep/build.xml
index 42de81a..d90f871 100644
--- a/libbrep/build.xml
+++ b/libbrep/build.xml
@@ -1,4 +1,6 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1">
+ <changeset version="16"/>
+
<model version="15">
<table name="build" kind="object">
<column name="package_tenant" type="TEXT" null="false"/>
diff --git a/libbrep/common.hxx b/libbrep/common.hxx
index 98fc4e7..b9b6928 100644
--- a/libbrep/common.hxx
+++ b/libbrep/common.hxx
@@ -373,13 +373,28 @@ namespace brep
// requirements
//
+ // Note that this is a 2-level nested container (see package.hxx for
+ // details).
+ //
+ using bpkg::requirement_alternative;
using bpkg::requirement_alternatives;
using requirements = vector<requirement_alternatives>;
+ #pragma db value(requirement_alternative) definition
#pragma db value(requirement_alternatives) definition
- using requirement_key = odb::nested_key<requirement_alternatives>;
- using requirement_alternatives_map = std::map<requirement_key, string>;
+ using requirement_alternative_key =
+ odb::nested_key<requirement_alternatives>;
+
+ using requirement_alternatives_map =
+ std::map<requirement_alternative_key, requirement_alternative>;
+
+ #pragma db value(requirement_alternative_key)
+
+ using requirement_key = odb::nested2_key<requirement_alternatives>;
+
+ using requirement_alternative_requirements_map =
+ std::map<requirement_key, string>;
#pragma db value(requirement_key)
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 1927298..38ca0ec 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -607,15 +607,36 @@ namespace brep
// requirements
//
- #pragma db member(requirement_key::outer) column("requirement_index")
- #pragma db member(requirement_key::inner) column("index")
+ // Note that this is a 2-level nested container which is mapped to three
+ // container tables each containing data of each dimension.
+ // Container of the requirement_alternatives values.
+ //
#pragma db member(requirements) id_column("") value_column("")
+
+ // Container of the requirement_alternative values.
+ //
+ #pragma db member(requirement_alternative_key::outer) column("requirement_index")
+ #pragma db member(requirement_alternative_key::inner) column("index")
+
#pragma db member(requirement_alternatives) \
virtual(requirement_alternatives_map) \
after(requirements) \
get(odb::nested_get (this.requirements)) \
set(odb::nested_set (this.requirements, std::move (?))) \
+ id_column("") key_column("") value_column("")
+
+ // Container of the requirement (string) values.
+ //
+ #pragma db member(requirement_key::outer) column("requirement_index")
+ #pragma db member(requirement_key::middle) column("alternative_index")
+ #pragma db member(requirement_key::inner) column("index")
+
+ #pragma db member(requirement_alternative_requirements) \
+ virtual(requirement_alternative_requirements_map) \
+ after(requirement_alternatives) \
+ get(odb::nested2_get (this.requirements)) \
+ set(odb::nested2_set (this.requirements, std::move (?))) \
id_column("") key_column("") value_column("id")
// tests
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 9e162ed..956e5d2 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -110,6 +110,52 @@
</references>
</foreign-key>
</add-table>
+ <alter-table name="package_requirement_alternatives">
+ <add-column name="enable" type="TEXT" null="true"/>
+ <drop-column name="id"/>
+ </alter-table>
+ <add-table name="package_requirement_alternative_requirements" kind="container">
+ <column name="tenant" type="TEXT" null="false"/>
+ <column name="name" type="CITEXT" null="false"/>
+ <column name="version_epoch" type="INTEGER" null="false"/>
+ <column name="version_canonical_upstream" type="TEXT" null="false"/>
+ <column name="version_canonical_release" type="TEXT" null="false" options="COLLATE &quot;C&quot;"/>
+ <column name="version_revision" type="INTEGER" null="false"/>
+ <column name="requirement_index" type="BIGINT" null="false"/>
+ <column name="alternative_index" type="BIGINT" null="false"/>
+ <column name="index" type="BIGINT" null="false"/>
+ <column name="id" type="TEXT" null="false"/>
+ <foreign-key name="tenant_fk" deferrable="DEFERRED">
+ <column name="tenant"/>
+ <references table="tenant">
+ <column name="id"/>
+ </references>
+ </foreign-key>
+ <foreign-key name="object_id_fk" on-delete="CASCADE">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ <references table="package">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </references>
+ </foreign-key>
+ <index name="package_requirement_alternative_requirements_object_id_i">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </index>
+ </add-table>
</changeset>
<model version="21">