[DBIx-Class-Devel] RFC: Comparison Helper

John Napiorkowski jjn1056 at yahoo.com
Thu Dec 13 14:21:05 GMT 2012


Frew,

Probably not that helpful, but tangential... =A0I think if we had a canonic=
al way to correctly serialized a schema, one that was perfectly roundtripp-=
able, perhaps the diff problem becomes just a problem of how to subtract - =
add to that serialization?

John



>________________________________
> From: fREW Schmidt <frioux at gmail.com>
>To: Discussion of DBIC development <dbix-class-devel at lists.scsys.co.uk> =

>Sent: Thursday, December 13, 2012 9:09 AM
>Subject: [DBIx-Class-Devel] RFC: Comparison Helper
> =

>A few times now I've wanted to be able to compare a schema against
>another schema.=A0 The general use case is that my tests are SQLite and
>should have the same data as my real database, but should not run all
>the actual migrations (slow tests are a drag.)=A0 Having thought about
>it for nearly three months I think I have some ideas on how it could
>be done.=A0 Here's the interface I'd use:
>
>=A0  # scalar context returns true for "same"
>=A0  # void dies
>=A0  my @differences =3D compare_resultsets({
>=A0 =A0 =A0 left =3D> {
>=A0 =A0 =A0 =A0  starting_points =3D> [
>=A0 =A0 =A0 =A0 =A0 =A0 $schema->resultset('User'),
>=A0 =A0 =A0 =A0  ],
>=A0 =A0 =A0 =A0  included_sources =3D> [
>=A0 =A0 =A0 =A0 =A0 =A0 $schema->source('User'),
>=A0 =A0 =A0 =A0 =A0 =A0 $schema->source('Permission'),
>=A0 =A0 =A0 =A0 =A0 =A0 $schema->source('Role'),
>=A0 =A0 =A0 =A0  ],
>=A0 =A0 =A0 },
>=A0 =A0 =A0 right =3D> {
>=A0 =A0 =A0 =A0  starting_points =3D> [
>=A0 =A0 =A0 =A0 =A0 =A0 $schema->resultset('User'),
>=A0 =A0 =A0 =A0  ],
>=A0 =A0 =A0 =A0  included_sources =3D> [
>=A0 =A0 =A0 =A0 =A0 =A0 $schema->source('User'),
>=A0 =A0 =A0 =A0 =A0 =A0 $schema->source('Permission'),
>=A0 =A0 =A0 =A0 =A0 =A0 $schema->source('Role'),
>=A0 =A0 =A0 =A0  ],
>=A0 =A0 =A0 }
>=A0  });
>
>The API might be able to get a little bit better, like allowing
>strings to automatically inflate where possible:
>
>=A0  compare_resultsets({
>=A0 =A0 =A0 included_sources =3D> [ qw(User Permission Role) ],
>=A0 =A0 =A0 starting_points =3D> ['User'],
>=A0 =A0 =A0 left_schema =3D> $left_schema,
>=A0 =A0 =A0 right_schema =3D> $right_schema,
>=A0  });
>
>And of course the above is just a whitelist, but blacklisting sources
>could be done if the user doesn't want to whitelist sources.=A0 The
>general idea is that I compare the (raw) values of the columns of each
>object, excluding auto_inc columns and fk columns pointing to an
>autoincs.=A0 Then I will traverse relationships (has_many only?) until I
>hit a source that is not included.=A0 I'm not sure how to avoid loops,
>but I'll cross that bridge when I get there.
>
>I have considered adding a way to whitelist/blackist down to the
>column level too, and that the autoinc/fk thing would just generate
>that, but that might be a level of configuration that's worthless.
>Not sure yet.
>
>Aside from the loop issue I'm fairly confident that this is doable and
>it is certainly useful to me.=A0 What do you guys think?
>
>--
>fREW Schmidt
>http://blog.afoolishmanifesto.com
>
>_______________________________________________
>DBIx-Class-Devel mailing list
>DBIx-Class-Devel at lists.scsys.co.uk
>http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class-devel
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/201212=
13/f47ee4de/attachment.htm


More information about the DBIx-Class-Devel mailing list