Skip to content

Commit

Permalink
Fix project URI uniqueness check.
Browse files Browse the repository at this point in the history
Sqitch was preventing the creation of more than one project with a `NULL` URI.
So removed the code that enforced that constraint (it wasn't even tested!).
Also, clarify the way project URIs work in the `init` docs and tutorials: It
does not allow multiple projects with the same name and different URIs, but
does prevent the use of multiple projects with the same name and different
URIs, or the the same name and a differnt URI.

Resolves #450.
  • Loading branch information
theory committed Apr 24, 2019
1 parent 1246eb9 commit 8c9aef5
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 24 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Revision history for Perl extension App::Sqitch
user when translations are provided. Defaults to the English "yes" and
"no" when no translation is available. Suggested by German translator
Thomas Iguchi (#449).
- Fixed a bug where only project without a URI was allowed in the
registry. Thanks to Conding-Brunna for the report (#450).
- Clarified the role of project URIs for uniqueness: They don't allow
multiple projects with the same name, but do prevent the deployment of
a project with the same name but different URI.

0.9999 2019-02-01T15:29:40Z
[Bug Fixes]
Expand Down
4 changes: 2 additions & 2 deletions lib/App/Sqitch/Engine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1862,8 +1862,8 @@ throws an exception
Registers the current project plan in the registry database. The
implementation should insert the project name and URI if they have not already
been inserted. If a project with the same name but different URI already
exists, an exception should be thrown.
been inserted. If a project already exists with the same name but different
URI, or a different name and the same URI, an exception should be thrown.
=head3 C<is_deployed_tag>
Expand Down
27 changes: 14 additions & 13 deletions lib/App/Sqitch/Role/DBIEngine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,21 @@ sub register_project {
# Both are undef, so cool.
}
} else {
# Does the URI already exist?
my $res = defined $uri ? $dbh->selectcol_arrayref(
'SELECT project FROM projects WHERE uri = ?',
undef, $uri
) : $dbh->selectcol_arrayref(
'SELECT project FROM projects WHERE uri IS NULL',
);
# No project with that name exists. Check to see if the URI does.
if (defined $uri) {
# Does the URI already exist?
my $res = $dbh->selectcol_arrayref(
'SELECT project FROM projects WHERE uri = ?',
undef, $uri
);

hurl engine => __x(
'Cannot register "{project}" with URI {uri}: project "{reg_proj}" already using that URI',
project => $proj,
uri => $uri,
reg_proj => $res->[0],
) if @{ $res };
hurl engine => __x(
'Cannot register "{project}" with URI {uri}: project "{reg_proj}" already using that URI',
project => $proj,
uri => $uri,
reg_proj => $res->[0],
) if @{ $res };
}

# Insert the project.
my $ts = $self->_ts_default;
Expand Down
3 changes: 2 additions & 1 deletion lib/sqitch-init.pod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ things that are already there.

Optional URI to associate with the project. If present, the URI will be
written to the project plan and used for added uniqueness in hashed object
IDs.
IDs, as well as to prevent the deployment of another project with the same
name but different URI.

=item C<--engine>

Expand Down
3 changes: 2 additions & 1 deletion lib/sqitchtutorial-exasol.pod
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ L<on GitHub|https://github.com/sqitchers/sqitch-exasol-intro>.
Now that we have a repository, let's get started with Sqitch. Every Sqitch
project must have a name associated with it, and, optionally, a unique URI. We
recommend including the URI, as it increases the uniqueness of object
identifiers internally, so let's specify one when we initialize Sqitch:
identifiers internally, and will prevent the deployment of a different project
with the same name. So let's specify one when we initialize Sqitch:

> sqitch init flipr --uri https://github.com/sqitchers/sqitch-exasol-intro/ --engine exasol
Created sqitch.conf
Expand Down
3 changes: 2 additions & 1 deletion lib/sqitchtutorial-firebird.pod
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ L<on GitHub|https://github.com/sqitchers/sqitch-firebird-intro>.
Now that we have a repository, let's get started with Sqitch. Every Sqitch
project must have a name associated with it, and, optionally, a unique URI. We
recommend including the URI, as it increases the uniqueness of object
identifiers internally, so let's specify one when we initialize Sqitch:
identifiers internally, and will prevent the deployment of a different project
with the same name. So let's specify one when we initialize Sqitch:

> sqitch init flipr --uri https://github.com/sqitchers/sqitch-firebird-intro/ --engine firebird
Created sqitch.conf
Expand Down
3 changes: 2 additions & 1 deletion lib/sqitchtutorial-mysql.pod
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ in these examples is L<on GitHub|https://github.com/sqitchers/sqitch-mysql-intro
Now that we have a repository, let's get started with Sqitch. Every Sqitch
project must have a name associated with it, and, optionally, a unique URI. We
recommend including the URI, as it increases the uniqueness of object
identifiers internally, so let's specify one when we initialize Sqitch:
identifiers internally, and will prevent the deployment of a different project
with the same name. So let's specify one when we initialize Sqitch:

> sqitch init flipr --uri https://github.com/sqitchers/sqitch-mysql-intro/ --engine mysql
Created sqitch.conf
Expand Down
3 changes: 2 additions & 1 deletion lib/sqitchtutorial-oracle.pod
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ Now that we have a repository, let's get started with Sqitch. Every Sqitch
project must have a name associated with it, and, optionally, a unique URI. We
recommend including the URI, as it increases the uniqueness of object
identifiers internally, so let's specify one when we initialize Sqitch:
identifiers internally, and will prevent the deployment of a different project
with the same name. So let's specify one when we initialize Sqitch:

> sqitch init flipr --uri https://github.com/sqitchers/sqitch-oracle-intro/ --engine oracle
Created sqitch.conf
Created sqitch.plan
Created deploy/
Expand Down
3 changes: 2 additions & 1 deletion lib/sqitchtutorial-snowflake.pod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ L<on GitHub|https://github.com/sqitchers/sqitch-snowflake-intro>.
Now that we have a repository, let's get started with Sqitch. Every Sqitch
project must have a name associated with it, and, optionally, a unique URI. We
recommend including the URI, as it increases the uniqueness of object
identifiers internally, so let's specify one when we initialize Sqitch:
identifiers internally, and will prevent the deployment of a different project
with the same name. So let's specify one when we initialize Sqitch:

> sqitch init flipr --uri https://github.com/sqitchers/sqitch-snowflake-intro/ --engine snowflake
Created sqitch.conf
Expand Down
3 changes: 2 additions & 1 deletion lib/sqitchtutorial-sqlite.pod
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ in these examples is L<on GitHub|https://github.com/sqitchers/sqitch-sqlite-intr
Now that we have a repository, let's get started with Sqitch. Every Sqitch
project must have a name associated with it, and, optionally, a unique URI. We
recommend including the URI, as it increases the uniqueness of object
identifiers internally, so let's specify one when we initialize Sqitch:
identifiers internally, and will prevent the deployment of a different project
with the same name. So let's specify one when we initialize Sqitch:

> sqitch init flipr --uri https://github.com/sqitchers/sqitch-sqlite-intro/ --engine sqlite
Created sqitch.conf
Expand Down
3 changes: 2 additions & 1 deletion lib/sqitchtutorial-vertica.pod
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ L<on GitHub|https://github.com/sqitchers/sqitch-vertica-intro>.
Now that we have a repository, let's get started with Sqitch. Every Sqitch
project must have a name associated with it, and, optionally, a unique URI. We
recommend including the URI, as it increases the uniqueness of object
identifiers internally, so let's specify one when we initialize Sqitch:
identifiers internally, and will prevent the deployment of a different project
with the same name. So let's specify one when we initialize Sqitch:

> sqitch init flipr --uri https://github.com/sqitchers/sqitch-vertica-intro/ --engine vertica
Created sqitch.conf
Expand Down
3 changes: 2 additions & 1 deletion lib/sqitchtutorial.pod
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ used in these examples is L<on GitHub|https://github.com/sqitchers/sqitch-intro>
Now that we have a repository, let's get started with Sqitch. Every Sqitch
project must have a name associated with it, and, optionally, a unique URI. We
recommend including the URI, as it increases the uniqueness of object
identifiers internally, so let's specify one when we initialize Sqitch:
identifiers internally, and will prevent the deployment of a different project
with the same name. So let's specify one when we initialize Sqitch:

> sqitch init flipr --uri https://github.com/sqitchers/sqitch-intro/ --engine pg
Created sqitch.conf
Expand Down

0 comments on commit 8c9aef5

Please sign in to comment.