[Jifty-commit] r5020 - in Jifty-DBI/branches/tisql: lib/Jifty
Jifty commits
jifty-commit at lists.jifty.org
Tue Feb 5 21:16:25 EST 2008
Author: ruz
Date: Tue Feb 5 21:16:24 2008
New Revision: 5020
Modified:
Jifty-DBI/branches/tisql/ (props changed)
Jifty-DBI/branches/tisql/Changes
Jifty-DBI/branches/tisql/README
Jifty-DBI/branches/tisql/SIGNATURE
Jifty-DBI/branches/tisql/lib/Jifty/DBI.pm
Log:
r4576 at cubic-pc (orig r4575): sartak | 2007-11-30 00:35:39 +0300
r48428 at onn: sartak | 2007-11-29 16:35:30 -0500
Release 0.48
Modified: Jifty-DBI/branches/tisql/Changes
==============================================================================
--- Jifty-DBI/branches/tisql/Changes (original)
+++ Jifty-DBI/branches/tisql/Changes Tue Feb 5 21:16:24 2008
@@ -1,5 +1,31 @@
Revision history for Perl extension Jifty::DBI.
+0.48 Thu Nov 29 16:28:11 EST 2007
+
+ * User and password values are excluded from the DSN in a more proper fashion
+ * Setting a default for RECORD_MIXINS and altering the mk_classdata() decls
+ to avoid any confusion with the mk_accessors() interface.
+ * Eliminated the ?: at the end of import() since RECORD_MIXINS is now [] by
+ default.
+ * Let users run arbitrary code during SQL statement logging
+ * Exclude user and passowrd from the DSN so it doesn't show up in the
+ terminal
+ * use YAML () -> require YAML to suppress error when YAML is not installed
+ (but ::Syck is installed)
+ * Fix reverse joins. Broken in multiple ways.
+ * added 'escape' option (undef by default) to Collection->limit, to allow "
+ * where column like 'something including wildcard(\\%)' ESCAPE '\\'" kind of
+ stuff, mainly for SQLite which doesn't seem to be able to escape wildcards
+ without ESCAPE
+ * changed escape character in the t/01searches.t from backslashes to at mar
+ * k, which is cleaner and kind to postgres; added pod
+ * typo fix in docs
+ * mysql doesn't handle bare varchar's
+ * TODO a test that needs us to force mysql to be case sensitive
+ * expand the escape documentation
+ * manifest skip pm_to_blib, add new test file to manifest
+ * Update Changes
+
0.47 Fri Nov 16 15:23:28 EST 2007
or, "The chmrr fixfest"
Modified: Jifty-DBI/branches/tisql/README
==============================================================================
--- Jifty-DBI/branches/tisql/README (original)
+++ Jifty-DBI/branches/tisql/README Tue Feb 5 21:16:24 2008
@@ -1,45 +1,172 @@
NAME
- Jifty::DBI - An object-relational mapper
+ Jifty::DBI - An object-relational persistence framework
DESCRIPTION
+ Jifty::DBI deals with databases, so that you don't have to.
This module provides an object-oriented mechanism for retrieving and
- updating data in a DBI-accesible database.
-
- This module is the direct descendent of DBIx::SearchBuilder. If you're familiar
- with SearchBuilder, Jifty::DBI should be quite familiar to you.
-
- Jifty::DBI was forked from SearchBuilder to give us the opportunity to seriously
- clean up the API and internals without breaking existing applications.
-
-INSTALLATION
-
- $ perl Makefile.PL
- $ make
- $ make test # but see below for how to actually test against a test database
- # make install
-
-TESTING
-
- In order to test most of the features of Jifty::DBI, you need
- to provide "make test" with a test database. For each DBI driver that
- you would like to test, set the environment variables "JDBI_TEST_FOO",
- "JDBI_TEST_FOO_USER", and "JDBI_TEST_FOO_PASS" to a database name, database
- username, and database password, where "FOO" is the driver name in all
- uppercase. You can test as many drivers as you like. (The appropriate
- "DBD::" module needs to be installed in order for the test to work.)
- Note that the "SQLite" driver will automatically be tested if
- "DBD::Sqlite" is installed, using a temporary file as the database. For
- example:
-
- JDBI_TEST_MYSQL=test JDBI_TEST_MYSQL_USER=root JDBI_TEST_MYSQL_PASS=foo \
- JDBI_TEST_PG=test JDBI_TEST_PG_USER=postgres make test
+ updating data in a DBI-accessible database.
-AUTHOR
- Copyright (c) 2001-2005 Jesse Vincent, jesse at fsck.com.
+ This module is the direct descendent of DBIx::SearchBuilder. If you're
+ familiar with SearchBuilder, Jifty::DBI should be quite familiar to you.
- All rights reserved.
+ What is it trying to do.
+ Jifty::DBI::Record abstracts the agony of writing the common and
+ generally simple SQL statements needed to serialize and de-serialize an
+ object to the database. In a traditional system, you would define
+ various methods on your object 'create', 'read', 'update', and 'delete'
+ being the most common. In each method you would have a SQL statement
+ like:
- This library is free software; you can redistribute it and/or modify it
- under the same terms as Perl itself.
+ select * from table where value='blah';
+
+ If you wanted to control what data a user could modify, you would have
+ to do some special magic to make accessors do the right thing. Etc. The
+ problem with this approach is that in a majority of the cases, the SQL
+ is incredibly simple and the code from one method/object to the next was
+ basically the same.
+
+ <trumpets>
+
+ Enter, Jifty::DBI::Record.
+
+ With ::Record, you can in the simple case, remove all of that code and
+ replace it by defining two methods and inheriting some code. It's pretty
+ simple and incredibly powerful. For more complex cases, you can do more
+ complicated things by overriding certain methods. Let's stick with the
+ simple case for now.
+
+ An Annotated Example
+ The example code below makes the following assumptions:
+
+ * The database is 'postgres',
+
+ * The host is 'reason',
+
+ * The login name is 'mhat',
+
+ * The database is called 'example',
+
+ * The table is called 'simple',
+
+ * The table looks like so:
+
+ id integer not NULL, primary_key(id),
+ foo varchar(10),
+ bar varchar(10)
+
+ First, let's define our record class in a new module named "Simple.pm".
+
+ use warnings;
+ use strict;
+
+ package Simple;
+ use Jifty::DBI::Schema;
+ use Jifty::DBI::Record schema {
+ column foo => type is 'text';
+ column bar => type is 'text';
+ };
+
+ # your custom code goes here.
+
+ 1;
+
+ Like all perl modules, this needs to end with a true value.
+
+ Now, on to the code that will actually *do* something with this object.
+ This code would be placed in your Perl script.
+
+ use Jifty::DBI::Handle;
+ use Simple;
+
+ Use two packages, the first is where I get the DB handle from, the
+ latter is the object I just created.
+
+ my $handle = Jifty::DBI::Handle->new();
+ $handle->connect(
+ driver => 'Pg',
+ database => 'test',
+ host => 'reason',
+ user => 'mhat',
+ password => ''
+ );
+
+ Creates a new Jifty::DBI::Handle, and then connects to the database
+ using that handle. Pretty straight forward, the password '' is what I
+ use when there is no password. I could probably leave it blank, but I
+ find it to be more clear to define it.
+
+ my $s = Simple->new( handle => $handle );
+
+ $s->load_by_cols(id=>1);
+
+ load_by_cols
+ Takes a hash of column => value pairs and returns the *first* to
+ match. First is probably lossy across databases vendors.
+
+ load_from_hash
+ Populates this record with data from a Jifty::DBI::Collection. I'm
+ currently assuming that Jifty::DBI is what we use in cases where we
+ expect > 1 record. More on this later.
+
+ Now that we have a populated object, we should do something with it!
+ ::Record automagically generates accessors and mutators for us, so all
+ we need to do is call the methods. accessors are named "column"(), and
+ Mutators are named "set_column"($). On to the example, just appending
+ this to the code from the last example.
+
+ print "ID : ", $s->id(), "\n";
+ print "Foo : ", $s->foo(), "\n";
+ print "Bar : ", $s->bar(), "\n";
+
+ Thats all you have to to get the data, now to change the data!
+
+ $s->set_bar('NewBar');
+
+ Pretty simple! Thats really all there is to it. Set<Field>($) returns a
+ boolean and a string describing the problem. Lets look at an example of
+ what will happen if we try to set a 'Id' which we previously defined as
+ read only.
+
+ my ($res, $str) = $s->set_id('2');
+ if (! $res) {
+ ## Print the error!
+ print "$str\n";
+ }
+
+ The output will be:
+
+ >> Immutable column
+
+ Currently Set<Field> updates the data in the database as soon as you
+ call it. In the future I hope to extend ::Record to better support
+ transactional operations, such that updates will only happen when "you"
+ say so.
+
+ Finally, adding and removing records from the database. ::Record
+ provides a Create method which simply takes a hash of key => value
+ pairs. The keys exactly map to database columns.
+
+ ## Get a new record object.
+ $s1 = Simple->new( handle => $handle );
+ my ($id, $status_msg) = $s1->create(id => 4,
+ foo => 'Foooooo',
+ bar => 'Barrrrr');
+
+ Poof! A new row in the database has been created! Now lets delete the
+ object!
+
+ my $s2 = Simple->new( handle => $handle );
+ $s2->load_by_cols(id=>4);
+ $s2->delete();
+
+ And it's gone.
+
+ For simple use, thats more or less all there is to it. In the future, I
+ hope to exapand this HowTo to discuss using container classes,
+ overloading, and what ever else I think of.
+
+LICENSE
+ Jifty::DBI is Copyright 2005-2007 Best Practical Solutions, LLC.
+ Jifty::DBI is distributed under the same terms as Perl itself.
Modified: Jifty-DBI/branches/tisql/SIGNATURE
==============================================================================
--- Jifty-DBI/branches/tisql/SIGNATURE (original)
+++ Jifty-DBI/branches/tisql/SIGNATURE Tue Feb 5 21:16:24 2008
@@ -14,11 +14,11 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-SHA1 cfe63a2a03694abfd1332bbbb2880a55053dbea8 Changes
-SHA1 fd34f72e662621963856904103782878cbdea4f0 MANIFEST
+SHA1 3334928687400b465f3a892a9658e48084c6c646 Changes
+SHA1 f559ca6ef0bd30360aad7c77fb6d4251158f87ed MANIFEST
SHA1 f489b63d4c48d37e3f60388dbac1e2ef9a571999 META.yml
SHA1 1e748530883277156c87f2ec864746ee8780d745 Makefile.PL
-SHA1 d0943ab047f543c92405564ab77ba008052544e6 README
+SHA1 ae8407c841f230c353f683bd5c257815aed9b9f0 README
SHA1 82d6ac3f6def48558d09f8b6e3b53ed4194d8c81 ROADMAP
SHA1 9d304f35438f847863969f6a069598379f5a9db2 debian/README
SHA1 603ce50bde12c6a3a91f28742ffd8a9d3917ec79 debian/changelog
@@ -40,42 +40,42 @@
SHA1 5d6189b2cad15cf9932a28faafd55130c8247e83 inc/Module/Install/Metadata.pm
SHA1 02af973fae2ac3531fa6b704574b2b8cb2a08148 inc/Module/Install/Win32.pm
SHA1 3a2eab96e91cca8d99938cda7791759ae9d97b3a inc/Module/Install/WriteAll.pm
-SHA1 89fe37d012cda5805f3147590e2384e8af2e68ea lib/Jifty/DBI.pm
-SHA1 cea6b04d9b0cc5f78ac62f4cac9429c4406fc816 lib/Jifty/DBI/Collection.pm
+SHA1 22e3f05e9262cc24a497f98efc3a92e0420bbffa lib/Jifty/DBI.pm
+SHA1 23294906d6424ae747d284ba03d6b7b71113405e lib/Jifty/DBI/Collection.pm
SHA1 639ef9c81f03fb084b312a5f9a6f6a3ff63b36b7 lib/Jifty/DBI/Collection/Union.pm
SHA1 bcba77fd2bacf0475aea1de97f57365c8de92ca6 lib/Jifty/DBI/Collection/Unique.pm
SHA1 049ce7a6d91bf5ae0dcfa5c3f50dfd6a682f8e70 lib/Jifty/DBI/Column.pm
SHA1 faf43ec59f8ebd094a1bdfc92eda92053d511e97 lib/Jifty/DBI/Filter.pm
SHA1 87192bf64a224cbea78770f4209ecae9981f3f5c lib/Jifty/DBI/Filter/Date.pm
-SHA1 9ea0d0d08c7c5d2cd8d924804db8e83202692ca0 lib/Jifty/DBI/Filter/DateTime.pm
+SHA1 70ffc9da2f13fc1aabd652169ba5a08b292ba678 lib/Jifty/DBI/Filter/DateTime.pm
SHA1 79649ca3fb9f8aa9d2fdda00d6d7c7c99fe4092f lib/Jifty/DBI/Filter/SaltHash.pm
SHA1 45ff3c7d2c03136acf98b74c659e2fe8c734d929 lib/Jifty/DBI/Filter/Storable.pm
SHA1 13837e1f389b4e2e60e8b2395b327604ec7e25b6 lib/Jifty/DBI/Filter/Time.pm
SHA1 83b92752da73eb8a88546509b4affaf57754ea66 lib/Jifty/DBI/Filter/Truncate.pm
-SHA1 d05dc7bc82040704770386705fdbdfd2fc326a57 lib/Jifty/DBI/Filter/YAML.pm
+SHA1 67ffe7188a1f529d7594f4fa3803bcbe15ba6485 lib/Jifty/DBI/Filter/YAML.pm
SHA1 9a6fd17e677321904436fefec4d434e17a4685b1 lib/Jifty/DBI/Filter/base64.pm
SHA1 deb33fa7b35f3542aac3e2d7fb4b5d3070dc3917 lib/Jifty/DBI/Filter/utf8.pm
-SHA1 d4c9bb38be8544e55c971ea58c2a46b67aac196f lib/Jifty/DBI/Handle.pm
-SHA1 9d07c7e4f629bd75d41a1ba88a7890fedaf8a9d3 lib/Jifty/DBI/Handle/Informix.pm
-SHA1 b924dfc77946ec22c292a405d4a26b46b457f775 lib/Jifty/DBI/Handle/ODBC.pm
-SHA1 51c8685ba23c00743cfa2b75e84d03efe54bca75 lib/Jifty/DBI/Handle/Oracle.pm
-SHA1 3ee23aa02b3dfd048dbb7a0d39040998ab7528b4 lib/Jifty/DBI/Handle/Pg.pm
+SHA1 759b75ddc720d400f610b2a460019eca902b8ae8 lib/Jifty/DBI/Handle.pm
+SHA1 bcc7c456e1c4d0dddd5564f03c8bb03a6c7e261f lib/Jifty/DBI/Handle/Informix.pm
+SHA1 338116a45f8eb6bfca5e76e8d3be78fb61fffe81 lib/Jifty/DBI/Handle/ODBC.pm
+SHA1 960fd0b63f3de11924c5d47a3c0c6d1db105ed5b lib/Jifty/DBI/Handle/Oracle.pm
+SHA1 2b64b747d072c67a510e79685cc08bebaf0a1402 lib/Jifty/DBI/Handle/Pg.pm
SHA1 860b373ddb0d0a1d001f20c721d9dffe003e2517 lib/Jifty/DBI/Handle/SQLite.pm
-SHA1 483de5eefde5ef2d194d18ad81a44b411122ad27 lib/Jifty/DBI/Handle/Sybase.pm
+SHA1 bba2314c20fcc3ef71cc69090f1cd6bd515cd9b4 lib/Jifty/DBI/Handle/Sybase.pm
SHA1 e6041a34c3044ed8b9691a5629ecf146fed95257 lib/Jifty/DBI/Handle/mysql.pm
SHA1 f2cc4fcce79c9a88a023d4e6bd96c2089eef1ced lib/Jifty/DBI/Handle/mysqlPP.pm
SHA1 0e975f9ec5480ca09025c592c06d484058e637df lib/Jifty/DBI/HasFilters.pm
-SHA1 fcbc3dc23809580c9cb180c9760533d688fa4d11 lib/Jifty/DBI/Record.pm
+SHA1 61579d4fb19bab8d89471ec1dc6afea0e86394e2 lib/Jifty/DBI/Record.pm
SHA1 1c8b4adcd312024a3408a52d3b2ef288c2084603 lib/Jifty/DBI/Record/Cachable.pm
SHA1 f4ec61cd857cb1cead8c9c5551047dc78734b73a lib/Jifty/DBI/Record/Memcached.pm
-SHA1 2ba30ea8380203b6d8c2905d4dca04e8facb1db6 lib/Jifty/DBI/Record/Plugin.pm
-SHA1 3e0ae61e9367260e7d33d9c7499483ac7b99e7c4 lib/Jifty/DBI/Schema.pm
-SHA1 eacc6f25b73a28b6fb262a01d0de534e6f127f91 lib/Jifty/DBI/SchemaGenerator.pm
+SHA1 6a70dc2a6fd6a5d77502d391ac2630d91a681c1a lib/Jifty/DBI/Record/Plugin.pm
+SHA1 08c285edcd05698b982c082f50da82fde02e4d31 lib/Jifty/DBI/Schema.pm
+SHA1 5594fb70d330523a9e6c7b5a1d2ea2f968be2615 lib/Jifty/DBI/SchemaGenerator.pm
SHA1 32834b7c4cf5a8d131382fccc8db341be8768291 t/00.load.t
SHA1 9aa7fed2b2409faa4c71d2a45db210721f47403e t/01-version_checks.t
SHA1 13c9fe3eeec0d000a7c86ea2474e30186cbc37e2 t/01basics.t
SHA1 018309dfc89440dc670cccf6138e3d4679465b47 t/01records.t
-SHA1 dfc9861164c5501a5ff1d1bbdc6aacde95e59e2b t/01searches.t
+SHA1 7574130aa1dc5338b6efcd0f04eca3f6dc4b2696 t/01searches.t
SHA1 933ebc7f0cfcaf03a2092a7c8271f98b2385f785 t/02-column_constraints.t
SHA1 90a5b9c663002e3c43a00b7f9a04d6ec2787500e t/02records_cachable.t
SHA1 33642a61fd4b5a88436a82c6dd0fef359ba74a2b t/02records_object.t
@@ -90,13 +90,14 @@
SHA1 bb91f506a251d7b27d2fcd29c482a345318ef04f t/06filter_yaml.t
SHA1 64c3722f5b34feafc87113257079721c174f3f96 t/10schema.t
SHA1 0f4655f0a4e558ac31df7b7fdf17c9b110f934da t/11schema_records.t
-SHA1 a32d11971659ee4e31a6acae9e2e9b8c138e3503 t/12prefetch.t
+SHA1 22a083137927a8635b02931e40f80c60220ec3a7 t/12prefetch.t
SHA1 a93e0ee622b2291f797887f663f33c30fc7339f6 t/13collection.t
-SHA1 f057b643275b0370ae18d47b3a1b394791c850d6 t/14handle-pg.t
+SHA1 41b7fbaf031d103a4f2066f177cc3bee84ab0458 t/14handle-pg.t
SHA1 4f41229caa246bf6ebb369010deb0c1eb8809666 t/15types.t
SHA1 5958e59e29d29fbf3862b5d3471472cbd82d191e t/16inheritance.t
SHA1 c7004285662f16abca274918f86d17ea43fe8c90 t/17virtualtypes.t
SHA1 cc7d6dd9889837143074729d30030ddabcfa6b9e t/18triggers.t
+SHA1 54b7727b49111162703581d13dd47dfe276fbe9a t/19reference.t
SHA1 5b3f8373687f89ccf3faf2dfbda9663137a8c078 t/case_sensitivity.t
SHA1 1dd9675b0a9a59fdcd300f5d92297f0ecf4f03e4 t/metadata.t
SHA1 59c44900b1cb957d262f96363ceff21b46e0d598 t/pod-coverage.t
@@ -104,9 +105,9 @@
SHA1 62742c946808f35bcc8b2777e975c1ce068a0a71 t/testmodels.pl
SHA1 2cf6ba23eb00dfed6f10533830da066c774c030c t/utils.pl
-----BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
+Version: GnuPG v1.4.7 (Darwin)
-iD8DBQFHMfTwEi9d9xCOQEYRAjLmAJ9xjRyeFnBdEkxbYzwPVPuQntYZtgCgt17o
-hIN0IYlFW4Hl48MDwSitjn8=
-=ry0L
+iD8DBQFHTzB0sxfQtHhyRPoRAtM9AJ9Cy4J75ED7ppZVxRT/Ar2wPvuLwwCgj8h3
+XrFbmqQ0xgMosHiFK7ieL6U=
+=S/Zy
-----END PGP SIGNATURE-----
Modified: Jifty-DBI/branches/tisql/lib/Jifty/DBI.pm
==============================================================================
--- Jifty-DBI/branches/tisql/lib/Jifty/DBI.pm (original)
+++ Jifty-DBI/branches/tisql/lib/Jifty/DBI.pm Tue Feb 5 21:16:24 2008
@@ -2,7 +2,7 @@
use warnings;
use strict;
-$Jifty::DBI::VERSION = '0.47';
+$Jifty::DBI::VERSION = '0.48';
=head1 NAME
More information about the Jifty-commit
mailing list