pax_global_header00006660000000000000000000000064116326775770014537gustar00rootroot0000000000000052 comment=42466eae97df7f69b0478bdc735ec200afd74cde ruby-dbi-0.4.5/000077500000000000000000000000001163267757700132625ustar00rootroot00000000000000ruby-dbi-0.4.5/ChangeLog000066400000000000000000003042251163267757700150420ustar00rootroot00000000000000== 0.4.0 - 08/23/2008 === Summary * Type conversion is now universally managed amongst DBDs. Please see DBI::Type and DBI::TypeUtil and the DBI::StatementHandle#bind_coltype method. * Rubygems support! All DBDs and DBI will now install and appropriately fetch prerequisites (when possible) via the 'gem' command and other Rubygems interfaces. * Lots of code has been cleaned up and the filesystem has been significantly reorganized. * Many bugfixes due to inconsistencies between DBDs. * DBDs that were deprecated in 0.2.0 have been removed, as have the Proxy and Trace libraries (they didn't work anyways.) Proxy and Trace will be revisited in the future. * Several calls and classes have been deprecated in favor of native ruby replacements. * Tons of new documentation for both DBI users and DBD developers alike. commit:: c717f76f0f9e3645d8a0e3a4d4daa6e0f2380273 Author:: Erik Hollensbe Date:: Sat Aug 23 01:48:08 2008 -0700 * Fixed test1.rb to include StatementHandle#finish. commit:: 0f1ef6e5e8babb9741b8300ed63d826eeeb6b98f Author:: Erik Hollensbe Date:: Sat Aug 23 00:59:46 2008 -0700 * Made the examples a little more in-your-face in the README. commit:: 10c81ba90ff766b0c28288ba065472d7ab2497d2 Author:: Erik Hollensbe Date:: Tue Aug 19 13:29:13 2008 -0700 * Changes to DBD version handling: DBI::VERSION is now used for comparison, and the comparison actually works. commit:: 10272829eb255580a40967458f0490649ea0584a Author:: Erik Hollensbe Date:: Tue Aug 19 12:52:37 2008 -0700 * Made native binding toggleable commit:: 0fba5e6125a48b4c38fe95818e96092ff2d46e0c Author:: Erik Hollensbe Date:: Tue Aug 19 11:40:46 2008 -0700 * Fix for new pg driver commit:: c4692c89ab6c392a9da0a82f4e43abf01a009bbc Author:: Erik Hollensbe Date:: Mon Aug 18 04:13:28 2008 -0700 * test to prove #20489 wrong commit:: af530d0103a80c16f305ea0e5fb6db1263119b50 Author:: Erik Hollensbe Date:: Fri Aug 15 11:51:48 2008 -0700 * "standard" pl/sql replacement for plpgsql function used for testing the last bug. not all postgres installations have plpgsql and there were other issues. commit:: 04c3371efb7fe37b5dbad88efd069e14287e9654 Author:: Erik Hollensbe Date:: Fri Aug 15 11:06:39 2008 -0700 * 0.4.0 fix for #21567, part 2. commit:: 2782db825e809bb0ebd93ac39d4a9318c3c76058 Author:: Erik Hollensbe Date:: Fri Aug 15 08:38:34 2008 -0700 * DBD::Pg documentation. commit:: 53d08b7b87b20b36bc0088498ec9aacc43e12def Author:: Erik Hollensbe Date:: Fri Aug 15 07:32:09 2008 -0700 * DBD::ODBC documentation commit:: 24c99b9296c9175082f67266327a6178442b0e69 Author:: Erik Hollensbe Date:: Fri Aug 15 07:14:35 2008 -0700 * A couple of touchups on the SQLite3 documentation commit:: dfe4a9faa80cb21d57d1535e41697fefd2ff717b Author:: Erik Hollensbe Date:: Thu Aug 14 13:06:46 2008 -0700 * Fix for #21567, modified for 0.4.0 * As a result, removed unnecessary fill_array method in Tuples class. commit:: 00fac0444f1e37404b1540e6ca7e8837e3627f63 Author:: Erik Hollensbe Date:: Wed Aug 13 06:13:40 2008 -0700 * DBD::SQLite3 commit:: 7fd22432756e088090aa8411063cbdf18c968ebe Author:: Erik Hollensbe Date:: Wed Aug 13 05:30:23 2008 -0700 * DBD::SQLite docs commit:: 1febe97a63a0da70869c46d6ec608e73ba66b310 Author:: Erik Hollensbe Date:: Wed Aug 13 03:47:39 2008 -0700 * Mysql::Statement docs * Fixed some formatting issues related to bullet lists and :: commit:: 9c8df9cbeb61a9520671837ac66d8ad0c8422c9b Author:: Erik Hollensbe Date:: Wed Aug 13 02:34:19 2008 -0700 * Mysql::Driver commit:: e1409c0fb791ddeca483c95aa32cf9e9f2a8c3c3 Author:: Erik Hollensbe Date:: Wed Aug 13 02:26:51 2008 -0700 * First stab at MySQL Docs * Base Namespace and Database documented commit:: 2646f291c2fb48ffdbe6b3c684a92fd89e8ddd9c Author:: Pistos Date:: Tue Aug 12 14:28:50 2008 -0400 Added English comment to gem installation lines. commit:: 7f4a757dc2bed50ebdaf6993062f4688a6d9b7d0 Author:: Pistos Date:: Tue Aug 12 14:26:09 2008 -0400 English edits on Exceptions section of DBI_SPEC. commit:: 11b8e19fb8a93fe2c9ad4691862d6e577a4cebcb Author:: Pistos Date:: Tue Aug 12 14:18:25 2008 -0400 Added "DBI::" namespace to titles for clarity. commit:: c83b56ee84115247d64f96fb921d04d289c8785a Author:: Pistos Date:: Tue Aug 12 14:15:07 2008 -0400 English edits in Classes section of DBI_SPEC. commit:: fdf38829a89a885a83d7d6a4625bff35e891d717 Author:: Pistos Date:: Tue Aug 12 14:12:08 2008 -0400 Changed UPPERCASE titles to Title Case. commit:: e9a22e7e0c38a0d2c5bca233b059b5e7a3e65a1c Author:: Pistos Date:: Tue Aug 12 14:11:48 2008 -0400 English edits on Design section of DBI_SPEC. commit:: 4b3d7bf730182cb320f7f76520586a79af53a6e7 Author:: Pistos Date:: Tue Aug 12 14:03:02 2008 -0400 English edits on DBI_SPEC foreword. commit:: a1a6fba702e308562b8f13e9d6a8373332f43961 Author:: Pistos Date:: Tue Aug 12 13:44:14 2008 -0400 Adjusted kitebird link title. commit:: 49ed014939701f4bdce9c359a46160b93c3e18d9 Author:: Pistos Date:: Tue Aug 12 13:44:05 2008 -0400 Added URI to github repo. commit:: cd58249dec1d26771d97c612020bbdf0f53be4c7 Author:: Pistos Date:: Tue Aug 12 13:41:25 2008 -0400 Changed most indentation in README from 3 to 4 spaces. commit:: e9b3e43176b39207562216cfde6d233943d7f95b Author:: Pistos Date:: Tue Aug 12 13:41:04 2008 -0400 English edit in README. commit:: 98511628a6316be2506cb3d61ec214b398032220 Author:: Pistos Date:: Tue Aug 12 13:33:48 2008 -0400 Added test/sql.log to .gitignore. commit:: 64d66c276e633496e1241f9fc5c0bd8a53c73496 Author:: Pistos Date:: Tue Aug 12 13:32:16 2008 -0400 Added .gitignore. Currently only ignoring rdocs. commit:: 89ed83c8ff1a61b46aaaa4765948fdffa9155efa Author:: Pistos Date:: Mon Aug 11 23:55:26 2008 -0400 Minor English change in README. commit:: 8e64908cc68797a3022cea8a281645c7c7852e55 Author:: Erik Hollensbe Date:: Sat Aug 9 22:51:49 2008 -0700 * New DBD_SPEC. Not sure if I like it yet. commit:: cdba7c7f461734e860b7f7ad140679418274022a Author:: Erik Hollensbe Date:: Sat Aug 9 05:49:33 2008 -0700 * Some cleanup on LICENSE and README commit:: c0825d7056fcb0c562d2481e5215eac05478419c Author:: Erik Hollensbe Date:: Sat Aug 9 05:41:52 2008 -0700 * DBI::Utils namespace complete commit:: 308533d39dd35a8f350d833b6f17fb84224cd49c Author:: Erik Hollensbe Date:: Sat Aug 9 05:20:30 2008 -0700 * DBI::Type, DBI::Type::*, DBI::TypeUtil commit:: 16cadf97edb581b1ba09bd73dcf03682e2e220e2 Author:: Erik Hollensbe Date:: Sat Aug 9 04:36:41 2008 -0700 * DBI::Row, DBI::SQL, DBI::SQL::PreparedStatement * Some start in on DBI::Type commit:: 0e67d266f30284418c8cf3bc6725a67991da7049 Author:: Erik Hollensbe Date:: Sat Aug 9 04:17:06 2008 -0700 * StatementHandle commit:: 1b3fd5b85a419742216e6e1644e0add6cc7d6377 Author:: Erik Hollensbe Date:: Sat Aug 9 02:55:24 2008 -0700 * DBI::Binary, DBI::ColumnInfo, All Handle classes except StatementHandle. commit:: bd90081b59da321d41ca5abb4704f74b24a67f3c Author:: Erik Hollensbe Date:: Sat Aug 9 02:00:30 2008 -0700 * DBI, BaseDatabase, BaseStatement, BaseDriver documented. * Some rdoc task tweaks. commit:: f69083b1e578c234614e79b954ed2cd8120c91bc Author:: Erik Hollensbe Date:: Fri Aug 8 03:57:38 2008 -0700 * Revised DBI SPEC commit:: fb4248efff21b4b929c179be2407750d88c29de7 Author:: Erik Hollensbe Date:: Fri Aug 8 03:11:42 2008 -0700 * README commit:: de1fe2b859109fe7be7c414917b77cbb93a83555 Author:: Erik Hollensbe Date:: Fri Aug 8 03:00:25 2008 -0700 * Rendered trace module impotent; this is going to have to be addressed in 0.6.0 commit:: f76bd745213c56394d1529748d6c5c479b561c25 Author:: Erik Hollensbe Date:: Fri Aug 8 02:08:35 2008 -0700 * bind_coltype implementation * DBI 0.4.0 is feature-complete commit:: 752532a90082986f21a3feec2c29951bdafa293c Author:: Erik Hollensbe Date:: Thu Jul 31 02:30:16 2008 -0700 * You can now turn off type management by twiddling the convert_types bit on DBI, and the Driver, Database, and Statement handles. * These changes will propogate upwards as new items are constructed * This is tested in test_types * Lots, lots, lots of fixes were made so this works properly commit:: 047576e57fcc5c2043115c7fe8df7c2ed963020b Author:: Erik Hollensbe Date:: Thu Jul 31 01:02:22 2008 -0700 * Fixed another regression I missed earlier * DBI::Row did shallow copies of the delegated array, which was causing problems with Pg arrays. Using a marshal dump/load method now, hope it's not too slow. commit:: 5a985a202efc3c0bc7dd7ef19ffe93a1ddd15b6d Author:: Erik Hollensbe Date:: Wed Jul 30 23:55:04 2008 -0700 * Found a pretty ugly bug in DBI::Row, which caused a lot of regressions that should have happened when I started the type changes. * Started to add some new tests commit:: fb3112aa212114c28fe1084030f470474219bc7c Author:: Erik Hollensbe Date:: Wed Jul 30 23:39:19 2008 -0700 * DBI::Row changes for convert_types; no tests yet commit:: 3299bcb6493cd46959641dd129be5f6d58ee01f2 Author:: Erik Hollensbe Date:: Wed Jul 30 23:34:23 2008 -0700 * Added convert_types to DBI, this is propogated up through the various handles. * Reformatted lib/dbi.rb commit:: 4d0f31673a840528b527b27719652bbf0a6ab8e2 Author:: Erik Hollensbe Date:: Wed Jul 30 23:28:52 2008 -0700 * Ok, convert_types works through the whole handler chain now (still untested) commit:: 45091467537e68cffd03c5be56a58d5b1f32b064 Author:: Erik Hollensbe Date:: Wed Jul 30 23:18:16 2008 -0700 * All handles now have a "convert_types" attribute * DatabaseHandles now use the "convert_types" attribute to determine if they are to convert types :) * the columns() method is now a required method for Database classes. Will raise NotSupportedError otherwise. commit:: 74ededbef484b7d4bfe8d16c34c0dc418b89a62a Author:: Erik Hollensbe Date:: Wed Jul 30 22:59:25 2008 -0700 * Converted all tests running w/ system() previously to now use rake's ruby(). This'll ensure the right ruby gets executed. commit:: c04f2e9f2328f2def41ee77925660fe7a78748e2 Author:: Erik Hollensbe Date:: Wed Jul 30 22:58:10 2008 -0700 * Rakefile changes: * test_dbi and test_dbd targets added to DBI rakefile. These test the DBD and DBI individually. * test target in DBI rakefile now depends on the above targets commit:: 2cb5402815de46f94ff72ea9a34ffe18d27061aa Author:: Erik Hollensbe Date:: Tue Jul 29 22:35:06 2008 -0700 * Removed a lot of obsolete files in the build/ directory commit:: 2d0f6b402449912f11999e89877b250e92b5bcb1 Author:: Erik Hollensbe Date:: Tue Jul 29 20:54:16 2008 -0700 * Gem prereqs for DBDs commit:: 9824637cdd2563627a95386fb05d4e1967dd65e1 Author:: Erik Hollensbe Date:: Tue Jul 29 20:01:14 2008 -0700 * ODBC fixes commit:: 0fb69f4f7af40df665afd29db13be7db8bbabced Author:: Erik Hollensbe Date:: Sun Jul 27 21:25:57 2008 -0700 * Fix for #5336 commit:: d993fd1b78981ee26d2d91218646f4fde500166e Author:: Erik Hollensbe Date:: Sun Jul 27 20:38:26 2008 -0700 * Q&D fix for null result set -> tableformatter - fix for #4944 commit:: 09fc86af845dc5bb8dbf2281c5b97b4716fe842f Author:: Erik Hollensbe Date:: Sun Jul 27 20:17:01 2008 -0700 * Finally fixed files left around from the postgresql/test_blob.rb test. Thanks again Mike Pomraning. commit:: a7519cbf170283b5e6f565d05982e0f753b572d1 Author:: Erik Hollensbe Date:: Sun Jul 27 20:09:06 2008 -0700 * Pg: integrated Mike Pomraning's patches from #18925: * async support * Native binds (yay) * TypeUtil: conversion cascade changes * Instead of checking if our object changed during a conversion attempt and cascading down if it didn't, we now have a cascade flag (true or false) which is used. This allows the driver to be more explicit. * Many, many, many of these changes were the result of this modification. commit:: 062447a9e228d66cdaf44ab1cdb73c2e09139149 Author:: Erik Hollensbe Date:: Sat Jul 26 17:24:49 2008 -0700 * Fix for Pg array parser and varchar elements (regression from \ fix in earlier commit) commit:: 7511f9b9794a9504f314159a073f6e3885a5aa83 Author:: Erik Hollensbe Date:: Sat Jul 26 17:08:36 2008 -0700 * Mysql couldn't store blobs properly (the blob test wasn't running.. whoops) * All strings were not properly escaping \ characters. commit:: 4426ac9a65fd05d84a09354e2a0e06f5331894d5 Author:: Erik Hollensbe Date:: Sat Jul 26 16:53:43 2008 -0700 * Some statement tests for ODBC commit:: afdda9620818e270666e5534851291db16122a87 Author:: Erik Hollensbe Date:: Sat Jul 26 16:46:57 2008 -0700 * ODBC working w/ general DBD tests * Reformatted lib/dbi/row.rb commit:: 5f5771a6bc69746f12e61622ee6b3f347253f520 Author:: Erik Hollensbe Date:: Sat Jul 26 13:50:35 2008 -0700 * Updated test/dbi/tc_dbi.rb reflecting Proxy.rb change commit:: 2e3d8a1d2aa1c94b4821ac1b3273dfbb9037db5c Author:: Erik Hollensbe Date:: Sat Jul 26 13:44:53 2008 -0700 * Proxy files are a goner; we'll resurrect them in 0.6.0 commit:: 4b447421ce0b4efdd93e49363db5c3389a445d1c Author:: Erik Hollensbe Date:: Sat Jul 26 13:41:40 2008 -0700 * TODO updates * bin/dbd_proxy never worked, it's now removed from release... hoping to touch on it in 0.6.0 * Removed un-used build/Rakefile.dbd.rb * Updated Rakefile.dbi.rb gemspec to contain 'dbi' as an executable commit:: 2f94d9439b06978cfa4f32b6050d3fa9c75db25e Author:: Erik Hollensbe Date:: Sat Jul 26 13:20:09 2008 -0700 * Lots of fixes to bin/dbi commit:: 2e9471d1b688aaaa6e2d4f493b0c267924af930f Author:: Erik Hollensbe Date:: Sat Jul 26 12:33:45 2008 -0700 * A few fixes to tableformatter and bin/dbi commit:: 68a62555c54897dd7d3ce2eef607739aa076f667 Author:: Erik Hollensbe Date:: Sat Jul 26 00:41:56 2008 -0700 * Fix for the DBI test that tests the version commit:: 76fbf73f56bb1f4c008299eab1c23d80f337bfa7 Author:: Erik Hollensbe Date:: Sat Jul 26 00:40:31 2008 -0700 * Bumped version on DBI so gems will still work and have proper deps commit:: d67ba5f69c8d47aa4dd007086f879ef5a685f6b1 Author:: Erik Hollensbe Date:: Sat Jul 26 00:37:20 2008 -0700 * Added dependencies for DBI * Played around with lib/dbi/trace.rb; it's not going to stay. updated TODO commit:: 0c1c2109f2599b96d22f2df2cb0accfb61d7a457 Author:: Erik Hollensbe Date:: Fri Jul 25 20:30:46 2008 -0700 * DBI and DBD Rakefiles both work as expected: * DBI Rakefile includes the right files in DBI and DBD packages * DBD .tar.gz and .zip files include all the tools to make gems, test, and repackage * DBDs now attempt to require DBI, this is to ensure that testing works without DBI in the package. commit:: e1eec1157fc79426d5d00ec6582bc16029a140ae Author:: Erik Hollensbe Date:: Thu Jul 24 18:13:44 2008 -0700 * new required DBD constant: DESCRIPTION, which describes the DBD's purpose. * Rakefile.dbi.rb is properly generating packages again commit:: 1136a81721598dee5812a9723690d0dfaa7b4212 Author:: Erik Hollensbe Date:: Thu Jul 24 17:55:20 2008 -0700 * Stage 2 of Rakefile changes commit:: 39c0cbb9e8a6c01653fac9c93e0ff188c2eb49dd Author:: Erik Hollensbe Date:: Thu Jul 24 17:25:13 2008 -0700 * Moved /Rakefile -> build/Rakefile.dbi - alterations will come in next commit commit:: 82a6d26d3e054239c72d528bab15c933537ec6f1 Author:: Erik Hollensbe Date:: Thu Jul 24 09:01:18 2008 -0700 * Created Rakefile.dbd (which does not work yet) for using with DBD packages * Removed the DOC_FILES addition in most package specs, this was already being included elsewhere commit:: 904ab1d452100b7c77e1b83dd679a83cb7b8630f Author:: Erik Hollensbe Date:: Thu Jul 24 08:16:26 2008 -0700 * Rakefile changes: * Stock 3.4.1 setup.rb in all .tar.gz's and .zip's now * LICENSE/README/etc in all packages * fixes to ensure all dbd portions are included * DBD-specific tests are now included in packages commit:: 556e08726d9716e5b06d558b8250eb9f0d06df9e Author:: Erik Hollensbe Date:: Wed Jul 23 17:28:00 2008 -0700 * removed bin/PATHCONV and translated the affected filenames commit:: 6d19af7147e4be01363613426610d29e00f72faa Author:: Erik Hollensbe Date:: Wed Jul 23 17:26:51 2008 -0700 * Moved scripts to bin directory instead of the subdir thing they were in commit:: e4b250f620eab7a2aa2f29de8fe70d066e0fdc1b Author:: Erik Hollensbe Date:: Wed Jul 23 17:16:27 2008 -0700 * Sybase DBD is GONE * New setup.rb commit:: b40c85c821a3ef36918386f7097646226d21c2eb Author:: Erik Hollensbe Date:: Wed Jul 23 16:08:10 2008 -0700 * Removed that nasty ColumnInfo mixin in the Mysql DBD commit:: 724ac6bf6d5642442eacd8e1b6254740574997ea Author:: Erik Hollensbe Date:: Wed Jul 23 16:06:44 2008 -0700 * Fixed DBD tests re: forcing all ColumnInfo keys to symbol commit:: b5c21526df27da7eafea5a9969d46d3fdd681e0a Author:: Erik Hollensbe Date:: Wed Jul 23 15:55:19 2008 -0700 * Removed a lot of cruft from ColumnInfo & Tests * Added deprecation warnings to the aliases provided in ColumnInfo commit:: 89ec97e6eb14268d7cc0a117bf4b3c7245a9a802 Author:: Erik Hollensbe Date:: Wed Jul 23 14:23:02 2008 -0700 * ColumnInfo is now a DelegateClass of Hash, instead of inheriting from Hash directly. commit:: bd9ff5bc608fadda89c9df4b57f321b35a5a83dd Author:: Erik Hollensbe Date:: Fri Jul 18 07:53:18 2008 -0700 * Added a nullable requirement for all drivers in dbh#columns. * Fixed a pretty nasty bug getting pkey/unique information in the Pg driver commit:: a12c25181800a258c4085a48925e15eb96295863 Author:: Erik Hollensbe Date:: Fri Jul 18 06:50:42 2008 -0700 * Precision/Scale tests: now works both in columns and column_info output for all drivers commit:: fa6df70c17e589d6977831543ceaf43885a5ba9d Author:: Erik Hollensbe Date:: Fri Jul 18 04:18:46 2008 -0700 * Integrated precision_test table into column and columninfo tests. Required collateral changes below. * New Type: DBI::Type::Decimal to represent DECIMAL and NUMERIC types, falls back to Float, parses to stdlib BigDecimal. * TypeUtil's generic conversion map was updated to handle this type and appropriately communicate it in a query. * MySQL treats NUMERIC/DECIMAL as type 246, which isn't in the TYPE_MAP and therefor never got mapped properly. * This impacted the sum bugfix from pre-0.2.0, converting it to BigDecimal. I think this is an improvement. commit:: b3584e283d86a95f128cf87133f6c355f57b0306 Author:: Erik Hollensbe Date:: Fri Jul 18 03:37:22 2008 -0700 * Added precision_test table to all DBD tests commit:: 73de88a98b1d4477c8309759bf3772e06a053d3c Author:: Erik Hollensbe Date:: Fri Jul 18 03:27:10 2008 -0700 * sth#column_info tests commit:: 989aa098eff6fa306a123d5cac6f6b0441c732fc Author:: Erik Hollensbe Date:: Fri Jul 18 03:12:35 2008 -0700 * Some dbh#columns tests that validate columninfo data across all DBDs commit:: ed963700ac6bdfaa91178d2fca56abb39fce4c34 Author:: Erik Hollensbe Date:: Fri Jul 18 02:58:30 2008 -0700 * Renamed ColumnInfo to DBI::ColumnInfo commit:: f6f18a7d39a689af1bc6cf426c9df9b5797677de Author:: Erik Hollensbe Date:: Fri Jul 18 02:38:14 2008 -0700 * Deprecated with warnings: DBI::Date, DBI::Timestamp, DBI::Time * Added gem dependency 'deprecated' gem commit:: 55322e5554dd690066f24b82bb4d152b07cb7bee Author:: Erik Hollensbe Date:: Wed Jul 16 10:26:25 2008 -0700 * Boolean tests commit:: 878a057cd7e0dac6982ebafe991d6c374a5cfd32 Author:: Erik Hollensbe Date:: Wed Jul 16 10:22:19 2008 -0700 * NULL type coercion * Fixed a *lot* of bugs related to these tests :) commit:: e9a8f0bf8da1a9a3314c0edce88c62e8ec5dd309 Author:: Erik Hollensbe Date:: Wed Jul 16 09:03:45 2008 -0700 * More type system tests commit:: afad45a26658ee9431b01983ef2eda1aed206cdf Author:: Erik Hollensbe Date:: Wed Jul 16 08:19:53 2008 -0700 * More type tests commit:: 172c87f5e6cb122094940727a3e939ddb0a0f76e Author:: Erik Hollensbe Date:: Wed Jul 16 08:11:13 2008 -0700 * test/dbi/tc_types.rb: DBI::Type and DBI::TypeUtil tests commit:: e0df6c9ae41c1f81a5156a9ab97d0e0defd052a2 Author:: Erik Hollensbe Date:: Wed Jul 16 07:32:00 2008 -0700 * Broke up SQLite3 driver commit:: c9d39cc800deb4f5738ad6f838d4024d16d2b7c3 Author:: Erik Hollensbe Date:: Wed Jul 16 07:18:22 2008 -0700 * Broke up SQLite driver commit:: d88476b1f969053bd1a577914c74329e7ad70dd7 Author:: Erik Hollensbe Date:: Wed Jul 16 07:14:35 2008 -0700 * Broke up Pg DBD commit:: 7ecc56e48076bd6e67aa054a2be120ec4b334a69 Author:: Erik Hollensbe Date:: Wed Jul 16 07:01:30 2008 -0700 * Even more readable commit:: 310d615b266ca7572dd0fcf6e64834419972b141 Author:: Erik Hollensbe Date:: Wed Jul 16 07:00:34 2008 -0700 * Base Mysql DBD a little more readable now commit:: 74de7ae7cb2ca09172a08208cb86d5b2cbc8e5fa Author:: Erik Hollensbe Date:: Wed Jul 16 06:59:26 2008 -0700 * Mysql DBD broken into several parts commit:: 7db39811774f0fd7e488784fa5376f45ae330ff2 Author:: Erik Hollensbe Date:: Wed Jul 16 06:39:29 2008 -0700 * removed unused version.rb file commit:: ca71d1cabc6c794928bb6dfe96deab0c083d6ee7 Author:: Erik Hollensbe Date:: Wed Jul 16 06:38:23 2008 -0700 * Moved DBI::TypeUtil to separate file commit:: d0f196c972f41e9abb1b766514b58265041bb75a Author:: Erik Hollensbe Date:: Wed Jul 16 06:34:22 2008 -0700 * Moved DBI::SQL:PreparedStatement to its own file commit:: 31aaffe228e109a8414102ad67bb80fc6701309b Author:: Erik Hollensbe Date:: Wed Jul 16 06:30:41 2008 -0700 * DBI::SQL::BasicBind and DBI::SQL::BasicQuote are now things of the past commit:: b53d794f89461972ef304656ba84679800c91a4b Author:: Erik Hollensbe Date:: Wed Jul 16 06:20:24 2008 -0700 * Broke up DBI::Utils::* namespace into separate files commit:: f8c4f21bfcfc23afeee9046e4df9b837aa9d91ad Author:: Erik Hollensbe Date:: Wed Jul 16 06:09:07 2008 -0700 * Nixed superfluous find require commit:: 748ab1688fd37e139fcef820cf4c44a01287681a Author:: Erik Hollensbe Date:: Wed Jul 16 06:08:17 2008 -0700 * Moved DBI::Base::* to separate files commit:: 0174ee2952308ca7f4528047372a4e2af6490b79 Author:: Erik Hollensbe Date:: Wed Jul 16 06:03:23 2008 -0700 * Broke handle classes out into separate files commit:: 001b38df88f6ac86a4c83fdcdee7503b85bdea2e Author:: Erik Hollensbe Date:: Wed Jul 16 05:57:06 2008 -0700 * Yanked DBI::Binary, Exception classes, and SQL_* constants out into their own files commit:: 6651c7ecacb195c89212e0899b2f24e8f8cac0b2 Author:: Erik Hollensbe Date:: Wed Jul 16 04:23:42 2008 -0700 * DBI and SQLite binding API slightly differs and both produce mildly different results when testing, the tests were modified to take advantage of this without copying code. commit:: d92b9e3a31f599ab0fb3502b5af87f1c49f99324 Author:: Erik Hollensbe Date:: Wed Jul 16 04:01:03 2008 -0700 * SQLite3 driver now works with new type system * Removed some deprecated fetch specializations that would never be called due to the new way fetch is handled commit:: f88beb99ddea04ed25b47a2148e759f777a65e39 Author:: Erik Hollensbe Date:: Tue Jul 15 23:28:26 2008 -0700 * Case-insensitive require fixes in DBI * Binding API fixes for MySQL commit:: 204ab87a01022a79d4a5e7781e22911944ab79f8 Author:: Erik Hollensbe Date:: Mon Jul 14 19:29:28 2008 -0700 * Cleaned up DBI tests. Removed several. commit:: eafb622a020b08664db9dffbbd7f28da96caf48a Author:: Erik Hollensbe Date:: Mon Jul 14 19:05:18 2008 -0700 * WARNING: Most DBI tests are broken right now * Gutted quoting system entirely, favoring the new type system to handle it. * ByteA is now a type, PGcoerce module is gone, gone, gone. * Removed quote instance methods in Pg, replaced with a quote class method for aiding types * All complex types use the E'' quoting syntax now, which should make Pg happier. * Small changes to the type system: * Conversions will now only cascade if the object remains unchanged. This prevents double-quoting. * All recognized types should be properly quoted now. commit:: 7c8e5242ef7f2b4764a07882769d1a920a934f6d Author:: Erik Hollensbe Date:: Mon Jul 14 16:46:11 2008 -0700 * Type conversion seems to be doing its job * ByteA probably still isn't working right. commit:: 1d9307bdb592168ac64bb6884b0d29c9231cfe5e Author:: Erik Hollensbe Date:: Mon Jul 14 15:05:03 2008 -0700 * New method: DBI::TypeUtil.type_name_to_module converts the type_name from columns output into a class * original functionality decoupled from DBI#column_types * DBI::DBD::Pg::Type::Array now has a base_type attribute to explain the encapsulated type * Pg columns now returns array types as a dbi_type with a constructed Array object as the value * More tests for Pg arrays commit:: 8df9e250bc88a1e5af242b2ebe7340afbf1262e9 Author:: Erik Hollensbe Date:: Mon Jul 14 14:44:11 2008 -0700 * Pg array -> Ruby array parser (with types) working now commit:: c0747f49424fe482d503008c1ffebbb973b22534 Author:: Erik Hollensbe Date:: Mon Jul 14 13:05:38 2008 -0700 * An attempt at converting ruby arrays to Pg arrays in the Pg driver commit:: a43f3e3c1b4878c4ecb65c9d64ff79eb58680803 Author:: Erik Hollensbe Date:: Mon Jul 14 12:16:22 2008 -0700 * Shifted types of arrays: * Types in columns output will now reflect the base type of the array (integer, varchar, etc) * The flag "array_of_type" will be set to true if the column is an array * Note: there is still no indication of the dimensions or any information about those dimensions. commit:: f3c802c35b417118b29a948c91d3c736fd62c882 Author:: Erik Hollensbe Date:: Mon Jul 14 11:32:17 2008 -0700 * Lots of healthy TODO modification * test/dbd/postgresql/test_arrays.rb filled out a little bit commit:: 8aa84cd97503244f204efcf07afede10cc2827ea Author:: Erik Hollensbe Date:: Mon Jul 14 09:36:04 2008 -0700 * array table added for Pg commit:: e685648e01aed1cfbc47415faa6d7c4b94609798 Author:: Erik Hollensbe Date:: Mon Jul 7 03:16:30 2008 -0700 * DBI::DBD::DIR is *gone* * load_driver rewritten and simplified * new support methods to enumerate available DBDs commit:: 5481609ad0a18a56727b1582b15c33a0692011d9 Author:: Erik Hollensbe Date:: Mon Jul 7 02:40:34 2008 -0700 * Removed all deprecated drivers (see TODO list for current exceptions) * Updated TODO commit:: 7ac4465c99a24708d93d3f99dd688db0c981e4f2 Author:: Erik Hollensbe Date:: Mon Jul 7 02:39:13 2008 -0700 * Pg array test stub commit:: 4bc3429cb83caec67e6019a94c75d80577d41dab Author:: Erik Hollensbe Date:: Thu Jun 12 12:50:03 2008 -0700 * Fixed a faulty tables test that will never be consistent across many postgresql versions commit:: 4553990f05884ec9e57bd7b4a21bc9f12eb3edc2 Author:: Erik Hollensbe Date:: Fri Apr 25 04:37:55 2008 -0700 * Indentation fixes to Mysql driver commit:: e7f7fcbff57f79da9ff5b99c702ea9d77c06cedb Author:: Erik Hollensbe Date:: Fri Apr 25 04:33:40 2008 -0700 * Mysql driver/tests updated for types API commit:: bce8e2388b5b4cc911ebe6ac047f20bf942ee269 Author:: Erik Hollensbe Date:: Fri Apr 25 04:13:51 2008 -0700 * Added a couple of comments. commit:: 458f3212cdee4fa7ccfae696d63b4d59df59946c Author:: Erik Hollensbe Date:: Fri Apr 25 04:12:50 2008 -0700 * Removed dead code commit:: a68b55ccf2eaa8f46b095c91820efd423159f446 Author:: Erik Hollensbe Date:: Fri Apr 25 04:11:51 2008 -0700 * Some indentation fixes commit:: 58fced679c997a34533a3b73b9a2c61a44976959 Author:: Erik Hollensbe Date:: Fri Apr 25 04:07:10 2008 -0700 * Postgresql driver/tests working commit:: 0c4fb698b5b87a4c359223c54626e841be746ff1 Author:: Erik Hollensbe Date:: Fri Apr 25 02:21:54 2008 -0700 * Fixed DBI tests commit:: aace8131284ec5dea62d147eb4f1486aa88211ee Author:: Erik Hollensbe Date:: Fri Apr 25 02:15:10 2008 -0700 * Fixed sqlite tests commit:: 6345cd1a6929ef396c4f661220e1a8e1eda9f1d2 Author:: Erik Hollensbe Date:: Fri Apr 25 02:14:10 2008 -0700 * Fixed sqlite3 tests commit:: ec003651a813c8dc1a3408bc332fb139dd02a3a4 Author:: Erik Hollensbe Date:: Wed Apr 23 21:19:39 2008 -0700 * Starting in on fixes to the pg driver * Lots of test changes -- mostly storing statement handles as a class var so we can finish them if the test fails commit:: 87d084e9e12fbe1e9e853d3ad3c4c73f21b4c033 Author:: Erik Hollensbe Date:: Thu Apr 17 17:18:01 2008 -0700 * Fix for the Rakefile that tests the ability to require the drivers before building namespaces for them * Many fixes to test/dbd/general/test_types * Many fixes to SQLite3 driver regarding type handling commit:: 41e082f10a697ab072fa77cf125d91d3131c726d Author:: Erik Hollensbe Date:: Thu Apr 17 14:22:18 2008 -0700 * removed some commented out code from the SQLite3 driver. commit:: 6801d689c01782242d92546fe290142cabbd589a Author:: Erik Hollensbe Date:: Thu Apr 17 14:06:58 2008 -0700 * Null handling * removed type conversion from SQLite driver commit:: 6b53384d47c2b946e811128a49c844c4f49dd921 Author:: Erik Hollensbe Date:: Thu Apr 17 13:53:08 2008 -0700 * Fixed Date/Time parsing commit:: 8b76da9c00dcb6cbb32c88ae00f116443eb8905e Author:: Erik Hollensbe Date:: Thu Apr 17 13:43:26 2008 -0700 * Inbound parameter conversion commit:: f72d55ab4dd321b4668dfc239758c9c68ba8d83b Author:: Erik Hollensbe Date:: Thu Apr 17 12:27:19 2008 -0700 * Moved parse logic from SQLite3 driver to DBI::StatementHandle#column_types commit:: 27938c99e9986cc4ba9cc2fe395dd25909772c80 Author:: Erik Hollensbe Date:: Thu Apr 17 12:21:48 2008 -0700 * A basic dry-run of DBI::Type.parse for various types commit:: 2cc28948db2205073fc2f86067cd7fafc189bd16 Author:: Erik Hollensbe Date:: Thu Apr 17 11:23:58 2008 -0700 * Added dbi/types to require list * Added a copyright notice in the source commit:: fadc02793d86ffdf4dea84cb71f727a8b5ce9f72 Author:: Erik Hollensbe Date:: Mon Apr 14 12:00:54 2008 -0700 * Added a StatementHandle#dbh parameter to get the dbh that created the statement handle commit:: 99304f17ca5cc5cbe8b7caddc917f259d2d71d70 Author:: Erik Hollensbe Date:: Mon Apr 14 10:06:21 2008 -0700 * Added a "driver_name" property to DatabaseHandles that yields the driver name information as a string. * Reformatted the majority of dbi.rb commit:: ec63e12741da5cd40b9a7ac3b26e15ee622d4d4c Author:: Erik Hollensbe Date:: Fri Apr 4 08:38:51 2008 -0700 ColumnInfo sanity patch by Pistos commit:: b87cd704db9a6bf031255ae7ca30b70e0df621e0 Author:: Erik Hollensbe Date:: Sun Mar 30 22:20:23 2008 -0700 * Initial (untested) types implementation. Still workin' on it. commit:: f0c124d920ef6996ea63400686a563c6e89cf694 Author:: Erik Hollensbe Date:: Mon Mar 24 09:24:48 2008 -0700 * basic prototype/description of type handling commit:: 8a97a5dd173de711ed22a66d829fcb6b4cd06250 Author:: Erik Hollensbe Date:: Mon Mar 17 08:49:37 2008 -0700 * Rakefile's a little easier to decipher now * Each DBD has it's own version! commit:: d32cf2f2ceb161fb63768657b89f4ee2fd783b06 Author:: Erik Hollensbe Date:: Mon Mar 17 08:25:44 2008 -0700 * Reworked Rakefile to gem all supported DBDs and DBI separately == 0.2.0 - 03/16/2008 === Summary * SQLite (2.x) driver rewritten in ruby * SQLite (3.x) driver provided by Jun Mukai * Migrated DBD::Pg to 'pg' low-level library * bytea and LOB support for DBD::Pg * New DBD Test suite * Tons of bug fixes commit:: 7bc29dd74badd75daa99b4c1f2c97e93dbc6a405 Author:: Erik Hollensbe Date:: Fri Mar 14 11:13:48 2008 -0700 * Fixed two bugs in the Pg driver (thanks again Mike Pomraning): * A tables bug where the system tables were not being sent back. * A columns bug where the columns were not properly selected when the schema search path was altered. commit:: eaf228bdf1c992cd8c523872057e5d2e1901eb6d Author:: Erik Hollensbe Date:: Wed Mar 12 15:35:08 2008 -0700 * Fix for timestamp type handling under mysql commit:: ce4c59e0a60f0dc4bbd66cc84c1b2a50df17c6ca Author:: Erik Hollensbe Date:: Tue Mar 11 10:58:18 2008 -0700 * Some fixes for timestamp handling for SQLite3 commit:: beb4c5b31b355180761df024c6933e1b67a2f59c Author:: Erik Hollensbe Date:: Tue Mar 11 09:09:37 2008 -0700 * Patch provided by Mike Pomraning that gets timestamps in a sane fashion! commit:: a6d70ffb23bb0493cd73ebe38dd413a9d86173bd Author:: Erik Hollensbe Date:: Sat Mar 8 19:05:58 2008 -0800 * Fixed a DBI::Timestamp#to_s error commit:: 48690de14c144ac030b12a2a627db611a0ca257c Author:: Erik Hollensbe Date:: Sat Mar 8 01:19:42 2008 -0800 * Fix for #3916 - sth.any? and sth.rows.zero? not consistent across DBDs commit:: 55f118d3e54dc546b133083271d80caccf00ab53 Author:: Erik Hollensbe Date:: Sat Mar 8 00:34:51 2008 -0800 * Peter Schiller's thread-safety patch * Some more tests surrounding the row count and fetchable? commit:: b496e0d981891fad6291dc49161963a15f05472a Author:: Erik Hollensbe Date:: Thu Mar 6 22:55:07 2008 -0800 * Plenty of DBI::Time fixes (based on a patch from #7710 and tests that were written as generals) commit:: 679bde33924ee368322f7ece4509822e07e68955 Author:: Erik Hollensbe Date:: Thu Mar 6 21:42:00 2008 -0800 * #6965 Fix and test (not ideal, but it does work) commit:: 3819bd468b941465abaffd6b7adc5afa1ddd0406 Author:: Erik Hollensbe Date:: Thu Mar 6 21:11:06 2008 -0800 * #4727 integrated commit:: 32c0e5e6fea308cd52891bf6dac589ad84b29ba4 Author:: Erik Hollensbe Date:: Thu Mar 6 20:57:00 2008 -0800 * Applied patch from ticket #7711 commit:: 34286112df17fbdb7588f45b176a42fb3a77aaae Author:: Erik Hollensbe Date:: Sun Feb 24 12:56:35 2008 -0800 * Fixed bug #10466 commit:: 1f19663fd9b31b0f2f0a111f227220d5ee8cbe1d Author:: Erik Hollensbe Date:: Sun Feb 24 12:09:44 2008 -0800 * Fixed #1082 commit:: f3e6e077e4073c892d8449ec6e1912ffe9f76f95 Author:: Erik Hollensbe Date:: Sun Feb 24 12:02:23 2008 -0800 * ByteA fixes! commit:: 8668eb0c1561b49b144f4a56c3edc2bce90bc2a0 Author:: Erik Hollensbe Date:: Sun Feb 24 00:29:00 2008 -0800 * Fixed most of the LOB support (yay!) commit:: 32ac057631b16429051c90fa9aab3ed1bb560e32 Author:: Erik Hollensbe Date:: Sat Feb 23 23:35:19 2008 -0800 * Initial porting attempt from ruby-postgres to ruby-pg * Test fixes and additions == 0.1.2 - 02-Sep-2006 === General * Paul DuBois: test/dbi/tc_dbi.rb: DBI version number test failed because it was expected to be 0.1.0. (Should have been 0.1.1.) But 0.1.1 has been released, so update DBI version number and expected number in test to 0.1.2. == 0.1.1 - 12-Aug-2006 === General * Paul DuBois: README: Added URLs for the RubyForge DBI project. * Patrick May: removed misleading space in setup.rb config example. * Francis Hwang: fixed bug 597: behaviour of StatementHandle#fetch doesn't match DBI specification * incorporated Matthew Bloch's patch for handling bad timestamps like '0000-00-00 00:00:00' === MySQL * Paul DuBois: Mysql.rb. Expose additional attributes through Database::func(): :client_info (String), :client_version (Fixnum), :host_info (String), :info (String), :proto_info (Fixnum), :server_info (String), :stat (String), :thread_id (Fixnum). * Paul DuBois: Mysql.rb. Modified column_info method to support standard sql_type and type_name column attributes and MySQL-specific mysql_type_name attribute. MYSQL_to_XOPEN hash: Added LONGTEXT and BIT members, corrected length for BLOB and MEDIUMBLOB members. * Paul DuBois: Mysql.rb. Renamed column info attributes/methods: _type, _length, _max_length, _flags are now mysql_type, mysql_length, mysql_max_length, mysql_flags * Paul DuBois: Mysql.rb. Modified column_info method to support standard column attributes: nullable, primary, unique, indexed Modify column_info method to support MySQL-specific column attributes: _type, _length, _max_length, _flags * Paul DuBois: Mysql.rb. Test for sqlstate method using respond_to? rather than by raising an exception. Implemented mysql_compression={0|1} option in DSN to disable/enable compression of client/server protocol. (Default off.) Implemented mysql_client_found_rows={0|1} option in DSN to cause server to return rows-changed counts (0) or rows-matched counts (1) for statements that modify rows (mostly relevant for UPDATE). (Default is rows-changed counts) Bugfix: column_info calculated precision as col.length - col.decimals. Should be col.length (precision is not just the digits to left of decimal point). * Paul DuBois: Mysql.rb: Added state member value to DBI::DatabaseError exceptions for MySQL. If mysql-ruby doesn't define a sqlstate method that provides the SQLSTATE value, state is set to nil (which is the default value anyway). * Paul DuBois: Mysql.rb: Enabled use of mysql_read_default_file and mysql_read_default_group options in DSN for MySQL. These options enable option files to be read. This change addresses bug #1951. * Paul DuBois: MySQL supports transactions. === SQLite * Daniel Berger: Removed hardcoded search paths to search path; Modified dir_config name to lower case == 0.1.0 - 16-Feb-2006 * Project taken over by Kirk Haines, Francis Hwang, Patrick May and Daniel Berger as of January, 2006 (with the permission of Michael Neumann). * Changelog style changed from diff style to summary style. If you want diffs, you can watch the CVS commits at http://ruby-dbi.rubyforge.org/statcvs/commit_log.html. * Old RUnit tests replaced with Test/Unit style tests. * Updated the README file to actually include useful documentation instead of pointing to an html document. * Lots of internal file/directory reorganization and renaming - none of which should matter to you. * General refactoring of the DBI::Row class including a bug fix where using multiple column references did not return the proper values. * Corresponding test suite additions and changes for DBI::Row. * Removed the dbrc.rb file from this distribution. The dbi-dbrc package can be downloaded separately from the RAA or installed as a gem. * Fixed bug #2793 (silent driver load failure). This also covers patch #603. * Fixed bug #1304 (comparing DBI::Timestamp with nil). * Fixed bugs #2099 (permissions issues on Windows). This also covers bug #2567. 2004-05-20 10:36 tag dbi-0-0-23 2004-05-20 10:36 Michael Neumann Changed: lib/dbi/version.rb (1.9), "Exp", lines: +2 -2 increased version 2004-05-20 10:33 Michael Neumann Added: build/README (1.1) initial creation 2004-05-20 10:31 Michael Neumann Changed: build/USER (1.4), "Exp", lines: +1 -0 added whole name of user andreas (for CVS changelog) 2004-05-20 10:28 Michael Neumann Changed: lib/dbd_odbc/ODBC.rb (1.10), "Exp", lines: +2 -2 modified email and copyright 2004-05-20 10:27 Michael Neumann Changed: lib/dbd_odbc/ODBC.rb (1.9), "Exp", lines: +20 -3 Implemented DNS-less connections, see [ruby-talk:67352] and [ruby-talk:100837] 2004-05-19 20:31 Michael Neumann Changed: lib/dbi/test/testsqlquote.rb (1.9), "Exp", lines: +1 -1 lib/dbi/sql.rb (1.18), "Exp", lines: +5 -2 Fixed problems with quoting Time's in Postgres (and probably some other databases). Time's are now represented as RFC-2822 strings, with numeric timezones and not timezone abbreviations (e.g. now +0200 instead CEST). According to Brad Hilton, there are problems with e.g. the IDT timezone which is used in different timezones. 2004-05-19 20:20 Michael Neumann Changed: lib/dbi/test/testsqlquote.rb (1.8), "Exp", lines: +6 -0 added testcase for quoting of Dates 2004-05-18 13:30 Andreas Schwarz Changed: ext/dbd_sqlite/SQLite.c (1.10), "Exp", lines: +3 -2 return number of changed rows in do(); closes #558 2004-05-13 14:24 Michael Neumann Changed: lib/dbd_oracle/Oracle.rb (1.7), "Exp", lines: +4 -3 Database#tables now returns tables AND views 2004-04-27 16:29 Michael Neumann Changed: lib/dbi/dbi.rb (1.42), "Exp", lines: +9 -1 lib/dbi/sql.rb (1.17), "Exp", lines: +3 -3 lib/dbi/test/testsqlcoerce.rb (1.5), "Exp", lines: +8 -0 * added comparison method DBI::Timestamp#== * DBI::SQL::BasicQuote::Coerce#as_timestampe: fixed conversion of timestamps when timezones like "+08:00" are given (instead "+08"). (Marek Janukowicz) 2004-04-26 08:40 Michael Neumann Changed: ext/dbd_sqlite/SQLite.c (1.9), "Exp", lines: +12 -2 raise exception if sql statement contains NUL characters (patch by Shirai,Kaoru) 2004-04-22 20:44 Michael Neumann Changed: build/package.sh (1.9), "Exp", lines: +4 -5 * 2004-04-22 20:10 tag dbi-0-0-22 2004-04-22 20:10 Michael Neumann Changed: lib/dbi/version.rb (1.8), "Exp", lines: +2 -2 new version 2004-04-22 20:08 Michael Neumann Changed: setup.rb (1.5), "Exp", lines: +1 -1 lib/dbd_pg/test/testdbipg.rb (1.2), "Exp", lines: +4 -4 lib/dbi/test/testrow.rb (1.6), "Exp", lines: +2 -2 lib/dbi/test/testsqlbind.rb (1.10), "Exp", lines: +4 -4 lib/dbi/test/testsqlcoerce.rb (1.4), "Exp", lines: +2 -2 lib/dbi/test/testsqlquote.rb (1.7), "Exp", lines: +2 -2 removed "don't put space before argument parentheses" warnings (ruby18) 2004-04-22 19:59 Michael Neumann Deleted: build/DBI-VERSIONS (1.7) build/create_changelog.rb (1.3) build/cvs2cl (1.2) doc/sf_logo.html (1.2) Added: build/cvs2cl.pl (1.1) Changed: build/Makefile (1.5), "Exp", lines: +3 -3 build/package.sh (1.8), "Exp", lines: +6 -14 doc/ToDo (1.2), "Exp", lines: +1 -0 doc/index.rd (1.34), "Exp", lines: +5 -3 moved to rubyforge. modified changelog generation. 2004-04-22 19:57 Michael Neumann Added: lib/dbd_frontbase/FrontBase.rb (1.1) lib/dbd_frontbase/README (1.1) Changed: lib/PATHCONV (1.11), "Exp", lines: +1 -0 imported FrontBase DBD (from Cail Borrell) 2004-04-22 18:46 Michael Neumann Changed: doc/index.rd (1.33), "Exp", lines: +18 -8 moved to rubyforge 2004-04-22 17:59 Michael Neumann Changed: setup.rb (1.4), "Exp", lines: +1 -1 remove parens warning 2003-11-05 20:46 Michael Neumann Changed: lib/dbi/dbi.rb (1.41), "Exp", lines: +2 -1 StatementHandle#execute returns nil instead for internal use intended DBI::Row object 2003-09-16 07:46 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.33), "Exp", lines: +13 -2 added methods Database#__set_notice_processor, Database#as_timestamp fixed unneeded overhead in Database#fill_array (submitted by Dennis Vshivkov) 2003-09-14 09:35 Michael Neumann Changed: ext/dbd_sqlite/SQLite.c (1.8), "Exp", lines: +2 -2 add timezone UTC to format (MoonWolf) 2003-09-11 20:57 Michael Neumann Changed: lib/dbi/dbi.rb (1.40), "Exp", lines: +3 -2 fixed warning (due to method redefinition) 2003-09-11 16:10 Michael Neumann Changed: doc/index.rd (1.32), "Exp", lines: +3 -1 added contributor 2003-09-11 16:08 Michael Neumann Changed: lib/dbd_db2/DB2.rb (1.7), "Exp", lines: +90 -41 added Database#columns method (by S. Veit) 2003-09-07 12:44 tag dbi-0-0-21 2003-09-07 12:44 Michael Neumann Changed: build/USER (1.3), "Exp", lines: +2 -2 modified email address 2003-09-07 12:41 Michael Neumann Changed: lib/dbi/version.rb (1.7), "Exp", lines: +2 -2 build/DBI-VERSIONS (1.6), "Exp", lines: +1 -0 new version 2003-09-07 12:40 Michael Neumann Changed: build/package.sh (1.7), "Exp", lines: +7 -0 added further dialog 2003-09-07 12:36 Michael Neumann Added: build/test.rb (1.1) lib/dbi/test/require_dispatch.rb (1.1) Changed: lib/dbi/row.rb (1.8), "Exp", lines: +3 -1 lib/dbi/test/testrow.rb (1.5), "Exp", lines: +13 -0 lib/dbi/test/testsqlbind.rb (1.9), "Exp", lines: +21 -2 lib/dbi/test/testsqlcoerce.rb (1.3), "Exp", lines: +3 -2 lib/dbi/test/testsqlquote.rb (1.6), "Exp", lines: +2 -1 * fixed DBI::Row.dup bug that occures in Ruby 1.8. * added tests for this and the SQL parse bug (/) 2003-06-10 21:40 Michael Neumann Changed: lib/dbi/sql.rb (1.16), "Exp", lines: +2 -1 lib/dbi/test/testsqlbind.rb (1.8), "Exp", lines: +7 -0 fixed SQL tokenizer bug: single slashes are preserved 2003-06-06 10:54 tag dbi-0-0-20 2003-06-06 10:54 Michael Neumann Changed: build/DBI-VERSIONS (1.5), "Exp", lines: +1 -0 lib/dbi/version.rb (1.6), "Exp", lines: +2 -2 new version 2003-06-06 10:48 Michael Neumann Changed: doc/index.rd (1.31), "Exp", lines: +5 -2 contributors added 2003-06-03 18:46 Michael Neumann Changed: lib/dbi/utils.rb (1.12), "Exp", lines: +4 -3 TableFormatter: convert false to "false", not "NULL" (MoonWolf) 2003-06-03 18:42 Michael Neumann Changed: ext/dbd_sqlite/SQLite.c (1.7), "Exp", lines: +62 -1 Database#columns method added (MoonWolf) 2003-05-31 15:52 Michael Neumann Changed: lib/dbi/utils.rb (1.11), "Exp", lines: +2 -2 fixed quoting bug ('\"' should be '"') in textconv (Brian Candler) 2003-05-18 20:18 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.32), "Exp", lines: +141 -24 applied array patches by Oliver M. Bolzer (DBD::Pg can now handle Postgres arrays) 2003-05-16 09:50 Michael Neumann Changed: doc/index.rd (1.30), "Exp", lines: +12 -2 new contributors; link to OCI8 DBD 2003-05-16 09:44 Michael Neumann Changed: lib/dbi/test/testsqlbind.rb (1.7), "Exp", lines: +12 -1 added new test cases for "-" bug 2003-05-16 09:43 Michael Neumann Changed: lib/dbi/test/testrow.rb (1.4), "Exp", lines: +1 -1 lib/dbi/test/testsqlcoerce.rb (1.2), "Exp", lines: +1 -1 lib/dbi/test/testsqlquote.rb (1.5), "Exp", lines: +1 -1 verbose mode 2003-05-16 09:43 Michael Neumann Changed: lib/dbi/sql.rb (1.15), "Exp", lines: +2 -1 bug fixed: "SELECT 1 - 3" was incorrectly transformed into "SELECT 1 3" 2003-05-14 19:52 Michael Neumann Added: ext/dbd_sqlite/test/segfault-bug.rb (1.1) Changed: ext/dbd_sqlite/SQLite.c (1.6), "Exp", lines: +2 -2 fixed bug: Prepared statement is executed twice: once with no match, once with a match. The second case fails and segfaults. 2003-05-14 18:36 Michael Neumann Added: ext/dbd_sqlite/test/test.rb (1.1) Changed: ext/dbd_sqlite/SQLite.c (1.5), "Exp", lines: +33 -6 Patch by : * fix Row Processed Count(sqlite_changes() function) * fix DBI::Timestamp quote format for Timestamp sorting before '2003-2-13 1.2.3.0' => after '2003-02-13 01:02:03' 2003-05-11 15:29 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.31), "Exp", lines: +25 -18 added NonBlocking execution mode 2003-05-11 15:27 Michael Neumann Changed: lib/dbi/dbi.rb (1.39), "Exp", lines: +13 -5 class Timestamp: - fraction nil by default - fractions may be of type float (as well as integer) - #to_s do not show fraction if it's nil 2003-05-09 19:54 Michael Neumann Changed: lib/dbi/dbi.rb (1.38), "Exp", lines: +5 -5 zero-pad date/time/timestamps (classes Date/Time/Timestamp method to_s) 2003-04-27 19:18 Michael Neumann Changed: build/package.sh (1.6), "Exp", lines: +1 -1 fixed RAA entry update address 2003-04-27 18:51 tag dbi-0-0-19 2003-04-27 18:51 Michael Neumann Changed: build/DBI-VERSIONS (1.4), "Exp", lines: +1 -0 build/USER (1.2), "Exp", lines: +1 -0 lib/dbi/version.rb (1.5), "Exp", lines: +2 -2 new version 2003-04-27 17:42 Michael Neumann Changed: lib/dbi/dbi.rb (1.37), "Exp", lines: +2 -2 bug fix in class DBI::Time (wrong named variable) 2003-04-27 17:40 Michael Neumann Changed: doc/index.rd (1.29), "Exp", lines: +4 -1 new contributor 2003-04-27 17:37 Michael Neumann Changed: lib/dbi/sql.rb (1.14), "Exp", lines: +4 -4 Fixed bug in DBI::SQL::BasicQuote::Coerce#as_time Mysql time columns (like "13:32:33") could not be converted into DBI::Time objects (thanks to Tim Bates) 2003-04-21 18:09 eliask Changed: lib/dbd_db2/DB2.rb (1.6.4.2), "Exp", lines: +34 -3 DB2 driver support for columns(table) 2003-04-02 15:42 Paul Dubois Changed: lib/dbd_mysql/Mysql.rb (1.21), "Exp", lines: +4 -4 Modify transaction support to use self.do rather than @handler.query so that query execution is routed through the mutex. 2003-02-08 02:26 Paul Dubois Changed: lib/dbi/dbi.rb (1.36), "Exp", lines: +19 -2 Fix bug in case insensitive driver name lookup on case insensitive filesystems 2003-02-08 02:03 Paul Dubois Changed: lib/dbd_mysql/Mysql.rb (1.20), "Exp", lines: +40 -3 Add transaction support: commit and rollback methods, AutoCommit database handle attribute 2003-02-08 01:46 Paul Dubois Changed: lib/dbd_mysql/Mysql.rb (1.19), "Exp", lines: +10 -10 return MySQL error number on exceptions, not just error message 2003-02-08 01:37 Paul Dubois Changed: lib/dbd_mysql/Mysql.rb (1.18), "Exp", lines: +5 -1 port and flag connection parameters must be passed as numbers 2003-02-08 00:37 Paul Dubois Changed: lib/dbd_mysql/Mysql.rb (1.17), "Exp", lines: +4 -4 Do not force user to provide database name when connecting 2003-02-01 13:51 Michael Neumann Changed: lib/dbi/test/testsqlbind.rb (1.6), "Exp", lines: +6 -0 added comment test 2003-02-01 13:45 Michael Neumann Changed: lib/dbi/sql.rb (1.13), "Exp", lines: +20 -5 method BasicBind#tokens: added support for C-style (non-nesting) and Ada/SQL92-style comments 2003-01-22 10:55 Michael Neumann Changed: doc/index.rd (1.27), "Exp", lines: +6 -1 added contributor, added Articles section 2003-01-22 10:52 Michael Neumann Changed: doc/DBD_SPEC (1.3), "Exp", lines: +2 -2 doc/DBI_SPEC (1.3), "Exp", lines: +2 -2 fixed wrong email address 2003-01-22 10:45 Michael Neumann Changed: doc/DBD_SPEC (1.2), "Exp", lines: +107 -103 doc/DBI_SPEC (1.2), "Exp", lines: +95 -92 Fix typos and formatting (by Paul DuBois). 2002-12-28 14:36 eliask Changed: lib/dbd_db2/DB2.rb (1.6.4.1), "Exp", lines: +216 -55 experimental support for BLOBs via SQLBindParameter 2002-10-28 11:18 Michael Neumann Changed: build/package.sh (1.5), "Exp", lines: +0 -3 # Removed the removing of empty dirs. Use cvs -P option (implicit) instead. 2002-10-28 11:05 Michael Neumann Changed: build/Makefile (1.4), "Exp", lines: +1 -1 build/package.sh (1.4), "Exp", lines: +1 -1 * 2002-10-25 12:48 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.30), "Exp", lines: +2 -2 rollback transactions on disconnect 2002-10-22 15:28 tag dbi-0-0-18 2002-10-22 15:28 Michael Neumann Changed: build/DBI-VERSIONS (1.3), "Exp", lines: +1 -0 * 2002-10-22 15:25 Michael Neumann Changed: doc/index.rd (1.26), "Exp", lines: +3 -1 contributor added 2002-10-22 15:15 Michael Neumann Changed: lib/dbi/trace.rb (1.3), "Exp", lines: +2 -1 remove warnings 2002-10-22 15:06 Michael Neumann Changed: lib/dbi/dbi.rb (1.35), "Exp", lines: +21 -12 Driver URLs are now case-sensitive when in SAFE mode >= 1. This prevent a security error. 2002-10-22 14:53 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.29), "Exp", lines: +70 -10 reverted to old transaction handling schema; removed usage of SET AUTOCOMMIT TO ON|OFF. 2002-10-22 14:00 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.28), "Exp", lines: +32 -6 Use PostgreSQL specific quoting function (PGconn.quote) instead of default if available. Use PGconn.escape_bytea instead of own __escape_bytea function if available. 2002-10-03 10:21 Michael Neumann Changed: build/package.sh (1.3), "Exp", lines: +2 -2 fixed bug 2002-10-03 09:53 tag dbi-0-0-17 2002-10-03 09:53 Michael Neumann Changed: lib/dbi/version.rb (1.3), "Exp", lines: +2 -2 new version 2002-10-03 09:49 Michael Neumann Added: build/package.sh (1.1) initial creation; handles all release steps 2002-10-02 18:56 Michael Neumann Deleted: doc/create_html (1.2) removed 2002-10-02 18:26 Michael Neumann Deleted: doc/html/index.html (1.26) removed 2002-10-02 18:10 Michael Neumann Added: doc/DBD_SPEC (1.1) doc/DBI_SPEC (1.1) doc/ToDo (1.1) moved from ../lib/dbi/doc 2002-10-02 18:04 Michael Neumann Added: build/DBI-VERSIONS (1.1) build/Makefile (1.1) build/USER (1.1) build/cl2html.sh (1.1) build/create_changelog.rb (1.1) build/cvs2cl (1.1) initial import 2002-10-02 17:53 Michael Neumann Changed: setup.rb (1.3), "Exp", lines: +7 -2 install on debian-unstable into /usr/local/lib/site_ruby/ (by Brad Hilton) 2002-09-26 18:41 Michael Neumann Changed: doc/index.rd (1.24), "Exp", lines: +3 -1 * 2002-09-26 18:37 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.16), "Exp", lines: +40 -8 add support for coercing column values (patch by Brad Hilton) 2002-09-26 13:40 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.27), "Exp", lines: +9 -14 removed method send_sql and inlined it's code instead (little speed improvement) 2002-09-26 13:32 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.26), "Exp", lines: +196 -196 converted tabs to spaces 2002-09-26 13:28 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.25), "Exp", lines: +22 -55 rewritten transaction handling (uses now Postgres' "SET AUTOCOMMIT ON|OFF") 2002-09-13 09:10 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.24), "Exp", lines: +13 -5 fix quoting backslashes bug (Brad Hilton) 2002-08-02 13:59 Michael Neumann Changed: contrib/dbrc/dbrc.rb (1.2), "Exp", lines: +18 -1 added dsn method, minor doc additions 2002-08-01 19:00 Michael Neumann Changed: lib/dbi/dbi.rb (1.34), "Exp", lines: +37 -16 added Date#to_time/to_date/mday/mday= Time#to_time Timestamp#mday/mday= (Dave Thomas) 2002-07-26 20:43 Michael Neumann Changed: lib/dbi/dbi.rb (1.33), "Exp", lines: +3 -3 Time/Date => ::Time/::Date 2002-07-26 20:41 Michael Neumann Changed: setup.rb (1.2), "Exp", lines: +1 -0 skip CVS directories (Dave Thomas) 2002-07-26 18:14 Michael Neumann Changed: doc/html/index.html (1.25), "Exp", lines: +23 -15 * 2002-07-26 18:13 Michael Neumann Changed: doc/index.rd (1.23), "Exp", lines: +5 -1 added contributors 2002-07-26 18:12 Michael Neumann Added: contrib/dbrc/README (1.1) contrib/dbrc/dbrc.rb (1.1) initial import 2002-07-26 17:56 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.23), "Exp", lines: +15 -11 enhanced conversion: default is to_str, added timestamp (with/without timezone) 2002-07-26 17:51 Michael Neumann Changed: lib/dbi/dbi.rb (1.32), "Exp", lines: +18 -4 added methods Timestamp#to_time/to_date (Dave Thomas) 2002-07-03 20:09 tag dbi-0-0-16 2002-07-03 20:09 Michael Neumann Changed: lib/dbi/version.rb (1.2), "Exp", lines: +2 -2 new version 2002-07-03 20:08 Michael Neumann Changed: doc/html/index.html (1.24), "Exp", lines: +19 -15 * 2002-07-03 20:07 Michael Neumann Changed: doc/index.rd (1.22), "Exp", lines: +3 -2 added contributor 2002-07-03 19:56 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.22), "Exp", lines: +37 -8 added Statement#fetch_scroll (patch by Stephen Davies) 2002-07-03 19:24 Michael Neumann Changed: lib/dbi/dbi.rb (1.31), "Exp", lines: +10 -1 Added StatementHandle#[] and #[]=. Updated DBI and DBD specs. 2002-07-03 19:22 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.21), "Exp", lines: +20 -2 Fixed semantic of method Statement#rows (affects also Database#do): Now returns the Row Processed Count instead of the number of rows in the result. The old behaviour is still available through method Statement#['pg_row_count']. 2002-07-03 16:51 Michael Neumann Changed: doc/html/index.html (1.23), "Exp", lines: +1 -1 * 2002-07-03 16:48 Michael Neumann Changed: bin/commandline/sqlsh.rb (1.3), "Exp", lines: +27 -2 bin/proxyserver/proxyserver.rb (1.3), "Exp", lines: +28 -2 doc/index.rd (1.21), "Exp", lines: +29 -18 doc/html/index.html (1.22), "Exp", lines: +46 -28 ext/dbd_sqlite/SQLite.c (1.4), "Exp", lines: +28 -7 lib/dbd_ado/ADO.rb (1.6), "Exp", lines: +27 -20 lib/dbd_db2/DB2.rb (1.6), "Exp", lines: +27 -10 lib/dbd_interbase/InterBase.rb (1.4), "Exp", lines: +27 -20 lib/dbd_msql/Msql.rb (1.2), "Exp", lines: +27 -18 lib/dbd_mysql/Mysql.rb (1.15), "Exp", lines: +27 -18 lib/dbd_odbc/ODBC.rb (1.8), "Exp", lines: +27 -20 lib/dbd_oracle/Oracle.rb (1.6), "Exp", lines: +29 -23 lib/dbd_pg/Pg.rb (1.20), "Exp", lines: +29 -1 lib/dbd_proxy/Proxy.rb (1.8), "Exp", lines: +27 -19 lib/dbd_sqlrelay/SQLRelay.rb (1.4), "Exp", lines: +27 -19 lib/dbi/dbi.rb (1.30), "Exp", lines: +28 -18 LICENSE (1.2), "Exp", lines: +22 -339 license changed from GNU GPL to BSD 2002-06-13 15:45 Michael Neumann Added: lib/dbd_pg/test/test_bytea.rb (1.1) initial creation 2002-06-13 15:45 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.19), "Exp", lines: +35 -4 added method Database#__encode_bytea; decode values of type bytea to string 2002-05-21 18:52 tag dbi-0-0-15 2002-05-21 18:52 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.14), "Exp", lines: +9 -4 added driver specific method Database#__insert_id 2002-05-21 18:41 Michael Neumann Changed: lib/dbi/dbi.rb (1.29), "Exp", lines: +2 -1 explicitly initialize @trace_mode and @trace_output in Handle#initialize (omits disturbing warning messages) 2002-05-21 18:36 Michael Neumann Added: examples/trace_test.rb (1.1) initial import 2002-05-21 18:33 Michael Neumann Added: lib/dbi/version.rb (1.1) Changed: lib/dbi/dbi.rb (1.28), "Exp", lines: +3 -5 moved VERSION from dbi.rb to version.rb 2002-05-14 18:07 tag dbi-0-0-14 2002-05-14 18:07 Michael Neumann Changed: lib/dbi/dbi.rb (1.27), "Exp", lines: +3 -3 updated version 2002-05-14 18:03 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.13), "Exp", lines: +24 -14 fixed bug: method #do and #execute both set query_with_result of the same underlying database object. This results in errors if you mix both method calls (not neccessarily called concurrently). Solution: Mutex. 2002-04-17 13:43 Michael Neumann Changed: doc/index.rd (1.20), "Exp", lines: +4 -2 added contributor 2002-04-17 13:38 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.18), "Exp", lines: +4 -3 cache calls to PGResult#result in class Tuples (by James F.Hranicky); which increases performance around factor 100. 2002-04-16 20:38 tag dbi-0-0-13 2002-04-16 20:38 Michael Neumann Changed: doc/index.rd (1.19), "Exp", lines: +6 -2 doc/html/index.html (1.21), "Exp", lines: +20 -16 * 2002-04-16 20:25 Michael Neumann Changed: doc/html/index.html (1.20), "Exp", lines: +40 -99 * 2002-04-16 20:24 Michael Neumann Changed: doc/index.rd (1.18), "Exp", lines: +16 -44 updates links to sf.net 2002-04-16 20:24 Michael Neumann Added: doc/sf_logo.html (1.1) initial import 2002-02-06 18:05 Michael Neumann Changed: lib/dbd_odbc/ODBC.rb (1.7), "Exp", lines: +5 -4 fixed bug in method columns 2002-02-06 17:27 Michael Neumann Changed: bin/proxyserver/proxyserver.rb (1.2), "Exp", lines: +5 -5 upgraded to DBD API 0.2 fixed bug (checking version numbers) 2002-02-06 17:26 Michael Neumann Changed: lib/dbd_proxy/Proxy.rb (1.7), "Exp", lines: +6 -7 upgraded to DBD API 0.2 2002-02-06 14:24 Michael Neumann Changed: lib/dbi/sql.rb (1.12), "Exp", lines: +2 -2 method SQL::BasicQuote::Coerce::as_timestamp: return nil if str is empty (Sean Chittenden) 2002-01-04 11:54 Michael Neumann Changed: lib/dbi/dbi.rb (1.26), "Exp", lines: +2 -2 new version 2002-01-04 11:52 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.12), "Exp", lines: +1 -5 lib/dbd_pg/Pg.rb (1.17), "Exp", lines: +1 -6 fixed bind_param bug by removing method bind_params 2002-01-04 11:52 Michael Neumann Changed: test/testdbi.rb (1.4), "Exp", lines: +13 -1 added test-case for bind_param bug (only in Mysql and Pg driver) 2002-01-02 00:54 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.16), "Exp", lines: +1 -5 removed duplicate definition for the [] accessor method (Sean Chittenden) 2001-12-28 14:07 tag dbi-0-0-12 2001-12-28 14:07 Michael Neumann Added: examples/xmlgen.rb (1.1) initial import 2001-12-28 13:19 Michael Neumann Changed: lib/dbd_sqlrelay/SQLRelay.rb (1.3), "Exp", lines: +128 -45 updated version by David Muse 2001-12-28 13:05 Michael Neumann Added: lib/dbi/test/testsqlcoerce.rb (1.1) initial creation 2001-12-28 10:18 Michael Neumann Changed: doc/html/index.html (1.19), "Exp", lines: +45 -24 * 2001-12-28 10:18 Michael Neumann Changed: doc/index.rd (1.17), "Exp", lines: +2 -2 fixed doc 2001-12-28 00:54 Michael Neumann Changed: lib/dbi/sql.rb (1.11), "Exp", lines: +6 -1 DBI::SQL::BasicQuote::Coerce: don't try to convert nil; instead return nil in this case 2001-12-14 15:16 Michael Neumann Changed: doc/index.rd (1.16), "Exp", lines: +17 -4 fixed doc-bug 2001-12-02 17:23 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.15), "Exp", lines: +8 -4 fixed bug (displayed wrong default values) in method columns 2001-11-26 00:12 Michael Neumann Changed: lib/dbd_oracle/Oracle.rb (1.5), "Exp", lines: +95 -7 included Jim Menards columns methods 2001-11-25 23:26 Michael Neumann Changed: lib/dbd_oracle/Oracle.rb (1.4), "Exp", lines: +17 -3 implemented ?-style parameter markers 2001-11-25 23:25 Michael Neumann Changed: lib/dbi/sql.rb (1.10), "Exp", lines: +4 -2 added attribute accessor for unbound in class PreparedStatement 2001-11-22 15:20 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.14), "Exp", lines: +16 -8 added method bind_params do no more call commit/rollback if not in transaction use class SQL::PreparedStatement 2001-11-22 14:27 Michael Neumann Changed: ext/dbd_sqlite/README (1.2), "Exp", lines: +4 -0 ext/dbd_sqlite/SQLite.c (1.3), "Exp", lines: +48 -38 ext/dbd_sqlite/extconf.rb (1.3), "Exp", lines: +4 -1 added type conversion 2001-11-22 14:27 Michael Neumann Changed: bin/PATHCONV (1.2), "Exp", lines: +1 -0 added proxyserver 2001-11-22 14:26 Michael Neumann Changed: lib/dbi/utils.rb (1.10), "Exp", lines: +11 -11 ext/dbd_sqlite/extconf.rb (1.4), "Exp", lines: +1 -4 * 2001-11-22 14:25 Michael Neumann Changed: lib/dbi/test/testsqlbind.rb (1.5), "Exp", lines: +54 -0 added test for class PreparedStatement 2001-11-22 14:25 Michael Neumann Changed: lib/dbi/dbi.rb (1.25), "Exp", lines: +31 -8 added constant SQL_TYPE_NAMES, for SQL_XXX constant to SQL type name mapping 2001-11-22 14:23 Michael Neumann Changed: lib/dbi/sql.rb (1.9), "Exp", lines: +60 -2 added class PreparedStatement 2001-11-22 14:21 Michael Neumann Changed: lib/dbd_odbc/ODBC.rb (1.6), "Exp", lines: +48 -32 fixed tables added ping, columns extended column_info 2001-11-22 14:19 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.11), "Exp", lines: +13 -19 use SQL::PreparedStatement to improve speed 2001-11-21 15:03 Michael Neumann Changed: ext/dbd_sqlite/SQLite.c (1.2), "Exp", lines: +219 -18 added conversion routine 2001-11-21 15:01 Michael Neumann Added: test/michael/sqlite.cfg (1.1) test/michael/sqlite/config.sh (1.1) test/michael/sqlite/setup.sh (1.1) test/michael/sqlite/teardown.sh (1.1) ext/dbd_sqlite/README (1.1) initial import 2001-11-17 17:17 Michael Neumann Added: bin/proxyserver/proxyserver.rb (1.1) moved from examples/ 2001-11-17 17:17 Michael Neumann Deleted: examples/proxyserver.rb (1.6) moved to bin/proxyserver 2001-11-17 15:53 Michael Neumann Changed: bin/commandline/sqlsh.rb (1.2), "Exp", lines: +41 -20 command-line option --file 2001-11-17 14:55 Michael Neumann Added: bin/PATHCONV (1.1) initial import 2001-11-17 14:54 Michael Neumann Added: bin/commandline/sqlsh.rb (1.1) refactored code; new feature irb/rb; moved from examples dir 2001-11-17 14:52 Michael Neumann Deleted: examples/sqlsh.rb (1.11) moved to bin/commandline 2001-11-14 14:11 tag dbi-0-0-11 2001-11-14 14:11 Michael Neumann Changed: lib/dbd_pg/test/test_blob.rb (1.2), "Exp", lines: +37 -4 improved blob test 2001-11-14 14:04 Michael Neumann Changed: ext/dbd_sqlite/extconf.rb (1.2), "Exp", lines: +2 -2 fixed 2001-11-14 14:04 Michael Neumann Changed: doc/html/index.html (1.18), "Exp", lines: +2 -2 * 2001-11-14 14:00 Michael Neumann Changed: doc/index.rd (1.14), "Exp", lines: +5 -1 doc/html/index.html (1.17), "Exp", lines: +3 -1 doc/index.rd (1.15), "Exp", lines: +2 -2 * 2001-11-14 13:41 Michael Neumann Changed: lib/dbi/dbi.rb (1.24), "Exp", lines: +2 -2 DatabaseError.new without arguments 2001-11-14 13:38 Michael Neumann Changed: ext/PATHCONV (1.2), "Exp", lines: +2 -1 new dbd 2001-11-14 13:38 Michael Neumann Added: ext/dbd_sqlite/SQLite.c (1.1) ext/dbd_sqlite/extconf.rb (1.1) initial import 2001-11-13 14:53 Michael Neumann Changed: examples/sqlsh.rb (1.10), "Exp", lines: +2 -2 abort table output with "a" 2001-11-13 14:52 Michael Neumann Changed: doc/html/index.html (1.16), "Exp", lines: +0 -0 * 2001-11-13 14:25 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.10), "Exp", lines: +18 -8 fixed quote fixed finish (method do => no result handle => nil.free => exception) 2001-11-13 14:25 tag dbi-0-0-10 2001-11-13 14:25 Michael Neumann Added: lib/dbd_mysql/test/blob_test.rb (1.1) initial import 2001-11-13 11:31 Michael Neumann Changed: lib/dbd_odbc/ODBC.rb (1.5), "Exp", lines: +2 -2 small fix 2001-11-13 11:29 Michael Neumann Changed: doc/html/index.html (1.15), "Exp", lines: +36 -20 * 2001-11-13 11:29 Michael Neumann Changed: doc/index.rd (1.13), "Exp", lines: +16 -1 lib/dbi/dbi.rb (1.23), "Exp", lines: +3 -3 new version 2001-11-13 11:00 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.13), "Exp", lines: +8 -4 improved Database#ping 2001-11-13 11:00 Michael Neumann Added: lib/dbd_pg/test/test_ping.rb (1.1) initial import 2001-11-12 20:27 Michael Neumann Changed: lib/PATHCONV (1.10), "Exp", lines: +1 -0 added SQLRelay 2001-11-12 20:25 Michael Neumann Changed: lib/dbd_sqlrelay/SQLRelay.rb (1.2), "Exp", lines: +69 -22 added AutoCommit, added fetch_scroll... 2001-11-12 19:40 Michael Neumann Added: lib/dbd_pg/test/test_blob.rb (1.1) initial creation 2001-11-12 19:37 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.12), "Exp", lines: +87 -2 added Databaseattribute: pg_client_encoding added driver specific functions in Database: blob_import, blob_export, blob_create, blob_open, blob_unlink and blob_read convert DBI::Binary objects to OID's and insert the content as BLOB 2001-11-11 20:57 Michael Neumann Added: lib/dbd_sqlrelay/SQLRelay.rb (1.1) initial import 2001-11-09 16:08 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.9), "Exp", lines: +3 -3 modified method column_info 2001-11-09 01:32 Michael Neumann Changed: lib/dbd_db2/DB2.rb (1.5), "Exp", lines: +59 -30 fixed several bugs 2001-11-08 23:45 Michael Neumann Added: test/michael/pg.cfg (1.1) test/michael/pg/config.sh (1.1) test/michael/pg/setup.sh (1.1) test/michael/pg/teardown.sh (1.1) initial import 2001-11-08 23:45 Michael Neumann Changed: test/testdbi.rb (1.3), "Exp", lines: +1 -1 fixed bug (skaro) 2001-11-08 23:31 Michael Neumann Changed: lib/dbi/sql.rb (1.8), "Exp", lines: +2 -2 corrected type prefix (DBI::) 2001-11-08 23:30 Michael Neumann Changed: lib/dbi/test/testsqlbind.rb (1.4), "Exp", lines: +1 -1 lib/dbi/test/testsqlquote.rb (1.4), "Exp", lines: +1 -1 fixed require (dbi instead of just sql) 2001-11-08 22:39 Michael Neumann Changed: lib/dbi/utils.rb (1.9), "Exp", lines: +9 -3 TableFormatter#ascii modified 2001-11-08 22:38 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.11), "Exp", lines: +21 -7 method columns: extract default value 2001-11-08 21:51 Michael Neumann Changed: examples/sqlsh.rb (1.9), "Exp", lines: +66 -12 added commands \dt (describe table), \s (short select) and \pl (page length) 2001-10-30 12:51 Michael Neumann Changed: doc/html/index.html (1.14), "Exp", lines: +2 -2 * 2001-10-30 12:51 Michael Neumann Changed: doc/index.rd (1.12), "Exp", lines: +2 -2 fixed typo 2001-10-22 16:08 Michael Neumann Changed: doc/html/index.html (1.13), "Exp", lines: +21 -15 * 2001-10-22 16:07 Michael Neumann Changed: doc/index.rd (1.11), "Exp", lines: +6 -2 new release 2001-10-22 16:05 Michael Neumann Changed: lib/dbi/dbi.rb (1.22), "Exp", lines: +17 -3 preced driver specific functions with __ 2001-10-22 15:59 Michael Neumann Changed: lib/dbd_odbc/ODBC.rb (1.4), "Exp", lines: +9 -3 added odbc_ignorecase option (submitted by Sean O'Halpin) 2001-10-10 13:33 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.8), "Exp", lines: +130 -7 added method StatementHandle#fetch_scroll added createdb, dropdb, reload, shutdown 2001-10-10 10:47 Michael Neumann Changed: lib/dbi/dbi.rb (1.21), "Exp", lines: +47 -40 method DBI.get_driver renamed to DBI._get_full_driver new method DBI.get_driver now returns only DriverHandle object added attribute reader for DBI::Handle 2001-10-10 10:39 Michael Neumann Changed: examples/proxyserver.rb (1.5), "Exp", lines: +2 -2 DBI.get_driver => DBI._get_full_driver 2001-09-07 13:39 tag dbi-0-0-9 2001-09-07 13:39 Michael Neumann Changed: doc/index.rd (1.10), "Exp", lines: +4 -1 doc/html/index.html (1.12), "Exp", lines: +19 -13 * 2001-09-05 21:56 Michael Neumann Changed: lib/dbi/sql.rb (1.7), "Exp", lines: +2 -2 fixed bug in "quote" (found by Steven Davies) 2001-08-30 14:34 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.10), "Exp", lines: +3 -3 lib/dbd_mysql/Mysql.rb (1.7), "Exp", lines: +5 -5 columns: size=>precision; decimal_digits=>scale 2001-08-30 14:30 Michael Neumann Changed: lib/dbi/dbi.rb (1.20), "Exp", lines: +4 -17 changed SQL_type constants 2001-08-30 14:10 Michael Neumann Changed: lib/dbd_db2/DB2.rb (1.4), "Exp", lines: +59 -10 column_info returns more info's 2001-08-30 14:06 Michael Neumann Changed: examples/proxyserver.rb (1.4), "Exp", lines: +2 -2 changed DBD version checking 2001-08-30 14:06 Michael Neumann Changed: lib/dbd_proxy/Proxy.rb (1.6), "Exp", lines: +8 -2 changed version checking 2001-08-30 14:05 Michael Neumann Changed: lib/dbd_odbc/ODBC.rb (1.3), "Exp", lines: +6 -4 removed patch required for Ruby/ODBC 0.4 2001-08-30 14:02 Michael Neumann Changed: doc/html/index.html (1.11), "Exp", lines: +77 -23 * 2001-08-30 14:01 Michael Neumann Changed: doc/index.rd (1.9), "Exp", lines: +44 -8 added more contributors; new example; updated dbd_odbc (required newer version) 2001-08-30 13:34 Michael Neumann Changed: lib/dbi/dbi.rb (1.19), "Exp", lines: +6 -47 moved DBI::ColumnInfo to own file columninfo.rb removed DBD::COMPATIBLE_API_VERSIONS (now use major/minor) 2001-08-30 13:31 Michael Neumann Changed: lib/dbi/row.rb (1.7), "Exp", lines: +4 -0 * 2001-08-30 13:31 Michael Neumann Added: lib/dbi/columninfo.rb (1.1) initial import (moved from dbi.rb) 2001-08-23 22:11 Michael Neumann Changed: lib/dbi/dbi.rb (1.18), "Exp", lines: +3 -2 added DBI::DBD::COMPATIBLE_API_VERSIONS 2001-08-23 22:09 Michael Neumann Changed: lib/dbd_proxy/Proxy.rb (1.5), "Exp", lines: +2 -2 fixed DBD problems 2001-08-23 22:09 Michael Neumann Changed: examples/proxyserver.rb (1.3), "Exp", lines: +2 -2 fixed DBD version problems 2001-08-23 22:05 Michael Neumann Changed: lib/dbd_proxy/Proxy.rb (1.4), "Exp", lines: +3 -3 fixed problems with different DBD version on the server side 2001-08-23 22:04 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.6), "Exp", lines: +105 -4 added Database#columns; by Eli Green 2001-08-23 21:47 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.9), "Exp", lines: +107 -2 added Database#columns from Eli Green 2001-08-23 20:59 Michael Neumann Changed: lib/dbi/dbi.rb (1.17), "Exp", lines: +107 -11 StatementHandle#column_info returns now array of DBI::ColumnInfo added class DBI::ColumnInfo added method DatabaseHandle#columns(table) and BaseDatabase#columns(table) 2001-08-21 21:01 Michael Neumann Changed: lib/dbi/utils.rb (1.8), "Exp", lines: +3 -3 fixed bug in XMLFormatter.table (found by Jim Menard) 2001-07-28 12:07 tag dbi-0-0-8 2001-07-28 12:07 Michael Neumann Added: examples/persistence.rb (1.1) Changed: doc/html/index.html (1.10), "Exp", lines: +90 -183 * 2001-07-28 11:58 Michael Neumann Changed: doc/index.rd (1.8), "Exp", lines: +8 -1 new version 2001-07-26 00:56 jweirich Changed: lib/dbi/row.rb (1.6), "Exp", lines: +3 -0 lib/dbi/test/testrow.rb (1.3), "Exp", lines: +28 -16 Fixed row.rb so that dup and clone work 2001-07-19 09:37 Michael Neumann Changed: lib/dbi/dbi.rb (1.16), "Exp", lines: +2 -3 fixed bug in load_driver (thanks to John Gorman) 2001-07-17 16:57 Michael Neumann Changed: lib/dbi/sql.rb (1.6), "Exp", lines: +3 -2 corrected quoting for Time, Date and DateTime 2001-07-11 21:54 Michael Neumann Changed: doc/index.rd (1.7), "Exp", lines: +5 -1 doc/html/index.html (1.8), "Exp", lines: +10 -3 * 2001-07-10 15:07 tag dbi-0-0-7 2001-07-10 15:07 Michael Neumann Changed: lib/dbi/dbi.rb (1.15), "Exp", lines: +3 -1 fixed bug; missing else-branch and return 2001-07-06 19:36 tag dbi-0-0-6 2001-07-06 19:36 Michael Neumann Changed: doc/html/index.html (1.7), "Exp", lines: +10 -3 * 2001-07-06 19:35 Michael Neumann Changed: lib/dbi/dbi.rb (1.14), "Exp", lines: +2 -1 fixed bug in load_driver (added return found) 2001-07-06 18:21 Michael Neumann Changed: doc/index.rd (1.6), "Exp", lines: +6 -2 new release 2001-07-06 18:16 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.8), "Exp", lines: +3 -2 added DBI URI parameter database additionally to dbname 2001-07-06 18:14 Michael Neumann Changed: lib/dbd_proxy/Proxy.rb (1.3), "Exp", lines: +8 -4 rewritten DBI URI parser (due to dsn=...;...;) 2001-07-06 18:14 Michael Neumann Changed: lib/dbi/utils.rb (1.7), "Exp", lines: +11 -3 added patch by John Gorman for Utils.parse_params to allow database:host instead of database=...;host=... 2001-07-06 18:13 Michael Neumann Changed: lib/dbi/dbi.rb (1.13), "Exp", lines: +35 -6 added case-insensitive DBD name patch by John Gorman (e.g. dbi:Mysql:... and dbi:mysql:... should both work) 2001-06-29 17:18 Michael Neumann Changed: lib/dbi/dbi.rb (1.12), "Exp", lines: +3 -3 lib/dbi/sql.rb (1.5), "Exp", lines: +1 -2 lib/dbi/utils.rb (1.6), "Exp", lines: +4 -4 removed some warnings 2001-06-29 03:27 jweirich Changed: test/testdbi.rb (1.2), "Exp", lines: +17 -17 Removed spaces before arg lists (warnings using -w) 2001-06-22 12:28 jweirich Deleted: lib/dbi/test/testdbi.rb (1.3) Added: test/README (1.1) test/testdbi.rb (1.1) test/example/config.sh (1.1) test/example/example.cfg (1.1) test/example/setup.sh (1.1) test/example/teardown.sh (1.1) Moved testdbi.rb to toplevel test dir. Added configurability 2001-06-18 13:59 Michael Neumann Changed: examples/sqlsh.rb (1.8), "Exp", lines: +76 -6 added input/output support 2001-06-18 13:49 Michael Neumann Changed: lib/dbi/utils.rb (1.5), "Exp", lines: +17 -1 added conv_param to convert Date/Time arguments to DBI::Date/Time 2001-06-18 13:48 Michael Neumann Changed: lib/dbi/sql.rb (1.4), "Exp", lines: +65 -1 added Masatoshi SEKI's Coerce class 2001-06-18 13:47 Michael Neumann Changed: lib/dbi/dbi.rb (1.11), "Exp", lines: +44 -9 improved DBI:: Date/Time/Timestamp classes, added automatic coercion from Date/automatic Time to DBI::Date/Time in parmeters 2001-06-18 13:45 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.7), "Exp", lines: +13 -19 added coercing from Masatoshi SEKI 2001-06-18 12:02 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.6), "Exp", lines: +16 -23 connection changed to "dbi:Pg:dbname=..;host=...;port=...;tty=;options=" 2001-06-17 20:04 jweirich Changed: lib/dbi/sql.rb (1.3), "Exp", lines: +41 -21 lib/dbi/test/testdbi.rb (1.2), "Exp", lines: +1 -1 lib/dbi/test/testsqlbind.rb (1.3), "Exp", lines: +71 -0 lib/dbi/test/testsqlquote.rb (1.3), "Exp", lines: +1 -1 Updated the sql binding methods to correctly ignore ? in a string. Tests also updated. 2001-06-11 12:59 Michael Neumann Changed: examples/sqlsh.rb (1.7), "Exp", lines: +2 -2 output available DBDs (call sqlsh.rb without params) even if an error occured 2001-06-11 12:58 Michael Neumann Changed: lib/dbi/trace.rb (1.2), "Exp", lines: +2 -1 added require "dbi" to work as "ruby -r dbi/trace myprog.rb" 2001-06-11 10:46 Michael Neumann Changed: doc/html/index.html (1.6), "Exp", lines: +22 -14 * 2001-06-11 10:45 Michael Neumann Changed: doc/index.rd (1.5), "Exp", lines: +13 -5 ChangeLog and ToDo section 2001-06-11 10:44 Michael Neumann Changed: lib/dbi/dbi.rb (1.10), "Exp", lines: +2 -21 version => 0.0.6, moved ToDo's into file doc/ToDo 2001-06-11 00:11 Michael Neumann Changed: lib/dbi/sql.rb (1.2), "Exp", lines: +19 -11 fixed bug found by Masatoshi SEKI in bind(self, "WHERE a=?", ["connected?"]) 2001-06-11 00:09 Michael Neumann Changed: lib/dbi/test/testrow.rb (1.2), "Exp", lines: +1 -1 lib/dbi/test/testsqlbind.rb (1.2), "Exp", lines: +10 -1 lib/dbi/test/testsqlquote.rb (1.2), "Exp", lines: +1 -1 require files in the directory below instead of installed (e.g. ../sql instead of dbi/sql) extended testsqlbind.rb (to check for a bug occured in 0.0.5) 2001-06-08 20:30 tag dbi-0-0-5 2001-06-08 20:30 Michael Neumann Changed: doc/index.rd (1.4), "Exp", lines: +2 -2 doc/html/index.html (1.5), "Exp", lines: +1 -1 changed downloads 2001-06-08 20:28 Michael Neumann Changed: lib/dbd_odbc/ODBC.rb (1.2), "Exp", lines: +2 -2 corrected data_sources ("dbi:ODBC:" + ...) 2001-06-08 20:21 Michael Neumann Added: lib/dbi/trace.rb (1.1) Changed: lib/dbi/dbi.rb (1.9), "Exp", lines: +36 -3 added tracing to DBI 2001-06-07 20:13 Michael Neumann Changed: examples/sqlsh.rb (1.6), "Exp", lines: +8 -4 added resuce when showing the available DSN 2001-06-07 19:12 Michael Neumann Changed: doc/html/index.html (1.4), "Exp", lines: +9 -1 lib/dbd_db2/DB2.rb (1.3), "Exp", lines: +40 -13 added fetch_scroll as well as Date/Time convertion for DB2 2001-06-07 19:10 Michael Neumann Changed: doc/index.rd (1.3), "Exp", lines: +6 -1 added ODBC 2001-06-07 19:06 Michael Neumann Changed: lib/dbi/dbi.rb (1.8), "Exp", lines: +29 -3 added classes Date and Time 2001-06-07 19:06 Michael Neumann Added: lib/dbd_odbc/ODBC.rb (1.1) Changed: lib/PATHCONV (1.9), "Exp", lines: +1 -0 initial import 2001-06-07 13:52 Michael Neumann Added: lib/dbd_msql/Msql.rb (1.1) Changed: doc/html/index.html (1.3), "Exp", lines: +8 -1 lib/PATHCONV (1.8), "Exp", lines: +1 -0 lib/dbd_mysql/Mysql.rb (1.5), "Exp", lines: +14 -5 added method do in Mysql initial import of Msql 2001-06-07 13:52 Michael Neumann Changed: doc/index.rd (1.2), "Exp", lines: +5 -1 mSQL added 2001-06-07 10:42 Michael Neumann Changed: lib/dbd_ado/ADO.rb (1.5), "Exp", lines: +12 -13 lib/dbd_db2/DB2.rb (1.2), "Exp", lines: +2 -2 lib/dbd_interbase/InterBase.rb (1.3), "Exp", lines: +30 -13 lib/dbd_mysql/Mysql.rb (1.4), "Exp", lines: +13 -16 lib/dbd_oracle/Oracle.rb (1.3), "Exp", lines: +38 -16 lib/dbd_pg/Pg.rb (1.5), "Exp", lines: +3 -3 lib/dbd_proxy/Proxy.rb (1.2), "Exp", lines: +21 -2 lib/dbi/dbi.rb (1.7), "Exp", lines: +2 -2 changed raising DBI::Error to DBI::DatabaseError changed method DBI::DatabaseError.new 2001-06-06 15:32 Michael Neumann Changed: lib/dbi/utils.rb (1.4), "Exp", lines: +5 -5 extended XMLFormatter methods row and table 2001-06-05 22:33 Michael Neumann Changed: lib/dbd_pg/doc/README (1.2), "Exp", lines: +10 -8 adapted towards new version 0.0.5 2001-06-05 22:30 Michael Neumann Changed: ext/dbd_sybase/doc/README (1.3), "Exp", lines: +4 -1 outdated 2001-06-05 22:28 Michael Neumann Changed: doc/html/index.html (1.2), "Exp", lines: +196 -1 added content 2001-06-05 22:25 Michael Neumann Added: doc/create_html (1.1) doc/index.rd (1.1) doc/html/rubyStyle.css (1.1) new README file 2001-06-05 22:23 Michael Neumann Changed: README (1.2), "Exp", lines: +1 -92 removed content, forward to doc/index.rd 2001-06-05 12:17 Michael Neumann Changed: examples/proxyserver.rb (1.2), "Exp", lines: +14 -5 improved some code 2001-06-05 12:14 Michael Neumann Changed: lib/dbd_interbase/InterBase.rb (1.2), "Exp", lines: +20 -4 added error handling => DBI::Error 2001-06-05 12:07 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.4), "Exp", lines: +4 -4 changed $! (.dup) to $!.type.to_s (to fix the DRbUnknown DBD::Proxy bug) 2001-06-05 12:06 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.3), "Exp", lines: +48 -12 added error handling -> DBI::Error added ?-parameter markers binding removed ::Mysql.quote because it didn't worked as expected 2001-06-05 10:28 Michael Neumann Changed: lib/dbd_ado/ADO.rb (1.4), "Exp", lines: +10 -3 fixed misbehaviour in #finish. now supports parameter markers 2001-06-05 09:44 Michael Neumann Changed: lib/dbi/utils.rb (1.3), "Exp", lines: +2 -2 fixed bug (one parenthese too much) 2001-06-04 14:24 Michael Neumann Changed: lib/PATHCONV (1.7), "Exp", lines: +1 -0 added Proxy 2001-06-04 14:23 Michael Neumann Added: lib/dbd_proxy/Proxy.rb (1.1) examples/proxyserver.rb (1.1) initial import 2001-06-04 14:22 Michael Neumann Changed: lib/dbi/dbi.rb (1.6), "Exp", lines: +25 -6 added DBI.get_driver (to access the underlying DBD-Driver), needed by ProxyServer @@driver_map contains now arrays of DBI::DriverHandle and DBD::Driver -> modified all methods which use it added checks in DatabaseHandle select_one, select_all, [], []= if it is already closed -> raise exemption 2001-06-04 14:15 Michael Neumann Changed: lib/dbi/row.rb (1.5), "Exp", lines: +10 -1 added methods to_h, field_names (alias to column_names) and fixed typo-bug 2001-06-04 14:13 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.3), "Exp", lines: +10 -0 added method DatabaseHandle#tables and modified load_type_map to return CHAR's 2001-06-02 19:20 Rainer Perl Changed: ext/dbd_sybase/extconf.rb (1.2), "Exp", lines: +1 -6 applied patch from Akinori MUSHA 2001-06-02 18:06 Rainer Perl Added: doc/html/index.html (1.1) added example web-index 2001-06-01 11:04 Michael Neumann Changed: lib/dbd_oracle/Oracle.rb (1.2), "Exp", lines: +117 -43 improved speed, fixed some bugs 2001-05-31 14:34 Michael Neumann Changed: examples/sqlsh.rb (1.5), "Exp", lines: +1 -2 fixed bug (rescue instead ensure), which had the consequence readline was never used 2001-05-31 14:18 Michael Neumann Changed: lib/dbd_mysql/Mysql.rb (1.2), "Exp", lines: +1 -1 changed in datasource, mysql to Mysql 2001-05-31 14:17 Michael Neumann Changed: lib/dbi/row.rb (1.4), "Exp", lines: +2 -0 added "include Enumerable" 2001-05-31 14:16 Michael Neumann Changed: lib/PATHCONV (1.6), "Exp", lines: +1 -1 install wrapper together with dbi 2001-05-31 13:54 Michael Neumann Changed: lib/dbi/row.rb (1.3), "Exp", lines: +4 -2 fixed bug, so size_or_arr can now be nil, which creates an Array of size col_names.size 2001-05-31 13:53 Michael Neumann Added: lib/wrapper/dbi.rb (1.1) initial creation 2001-05-31 13:53 Michael Neumann Changed: lib/PATHCONV (1.5), "Exp", lines: +1 -0 add directory wrapper which installs directly into site-ruby 2001-05-31 13:52 Michael Neumann Changed: examples/sqlsh.rb (1.4), "Exp", lines: +1 -1 removed double :: in DSN output 2001-05-31 13:28 Michael Neumann Added: lib/dbi/test/testdbi.rb (1.1) lib/dbi/test/testrow.rb (1.1) lib/dbi/test/testsqlbind.rb (1.1) lib/dbi/test/testsqlquote.rb (1.1) initial import of test-cases, from Jim Weirichs Postgesql DBD 2001-05-31 13:27 Michael Neumann Changed: lib/dbi/utils.rb (1.2), "Exp", lines: +47 -1 move some methods from dbi/dbi into this file 2001-05-31 13:26 Michael Neumann Added: lib/dbi/sql.rb (1.1) initial creation. extracted from Jim Weirichs basicquote.rb, basicbind.rb and Postgresql.rb (query?) 2001-05-31 13:25 Michael Neumann Changed: lib/dbi/row.rb (1.2), "Exp", lines: +120 -83 use delegator to Array many features added, e.g dbrow["firstname", "lastname", ...] => ['Michael', 'Neumann', ...] passed Jims testcase 2001-05-31 13:23 Michael Neumann Changed: lib/dbi/dbi.rb (1.5), "Exp", lines: +8 -42 moved module Utils into file dbi/utils.rb use Jim Weirichs SQL::BasicQuote 2001-05-31 13:19 Michael Neumann Changed: lib/dbd_ado/ADO.rb (1.3), "Exp", lines: +2 -2 use SQL.query? instead of own version 2001-05-31 13:18 Michael Neumann Added: lib/dbd_pg/test/testdbipg.rb (1.1) initial import from Jim Weirichs ruby-dbi-postgresql-28.05.2001.7.tgz changed Postgres to Pg 2001-05-31 13:17 Michael Neumann Added: lib/dbd_pg/doc/README (1.1) initial import from Jim Weirichs ruby-dbi-postgresql-28.05.2001.7.tgz 2001-05-31 13:16 Michael Neumann Changed: lib/dbd_pg/Pg.rb (1.2), "Exp", lines: +3 -12 extracted some goodies to dbi/sql.rb changed Postgresql to Pg 2001-05-31 13:14 Michael Neumann Added: lib/dbd_pg/Pg.rb (1.1) initial import from Jim Weirichs ruby-dbi-postgesql-28.05.2001.7.tgz 2001-05-31 13:13 Michael Neumann Changed: lib/PATHCONV (1.4), "Exp", lines: +1 -0 added dbd_pg 2001-05-31 10:21 Michael Neumann Changed: lib/dbd_ado/ADO.rb (1.2), "Exp", lines: +94 -12 fixed several bugs in fetch/fetch_scroll, now has more functionality 2001-05-31 10:20 Michael Neumann Changed: lib/dbi/dbi.rb (1.4), "Exp", lines: +5 -5 fixed constant multiple-assignment bug, (1..6) -> (1..6).to_a fixed exception-raising bug, parameters in DBI::Error now all optional fixed bug in fetch_scroll (rows -> row) 2001-05-31 10:18 Michael Neumann Changed: examples/sqlsh.rb (1.3), "Exp", lines: +64 -10 added new commands (commit, rollback, autocommit) fixed readline-bug, readline -> $stdin.readline 2001-05-30 18:59 Michael Neumann Changed: lib/dbi/dbi.rb (1.3), "Exp", lines: +9 -5 added StatementHandle#finished? added check in DatabaseHandle#execute/#prepare in block-form, if finished? before calling #finish changed require "x" -> require "dbi/x" 2001-05-30 18:43 Michael Neumann Added: lib/dbd_ado/ADO.rb (1.1) initial import 2001-05-30 18:40 Michael Neumann Changed: lib/PATHCONV (1.3), "Exp", lines: +1 -0 added ADO entry 2001-05-30 18:37 Michael Neumann Changed: examples/sqlsh.rb (1.2), "Exp", lines: +17 -3 don't rely on "readline", works now without 2001-05-30 12:51 Michael Neumann Added: examples/sqlsh.rb (1.1) examples/sqlsh.rb.new (1.1) examples/test1.pl (1.1) examples/test_blob.rb (1.1) examples/xmltest.rb (1.1) Changed: examples/test1.rb (1.2), "Exp", lines: +9 -22 initial import 2001-05-30 12:43 Michael Neumann Changed: lib/dbd_mysql/doc/HISTORY (1.2), "Exp", lines: +4 -1 lib/dbd_mysql/doc/README (1.2), "Exp", lines: +2 -2 new entry 2001-05-30 12:40 Michael Neumann Added: lib/dbd_oracle/Oracle.rb (1.1) initial import 2001-05-30 12:40 Michael Neumann Added: lib/dbd_interbase/InterBase.rb (1.1) added new DBDs initial import initial import 2001-05-30 12:40 Michael Neumann Added: lib/dbd_db2/DB2.rb (1.1) added new DBDs initial import 2001-05-30 12:40 Michael Neumann Changed: lib/PATHCONV (1.2), "Exp", lines: +5 -2 added new DBDs 2001-05-30 12:36 Michael Neumann Deleted: lib/dbd_mysql/dbd_mysql.rb (1.2) Added: lib/dbd_mysql/Mysql.rb (1.1) upgraded to new version 0.5 2001-05-29 11:22 Michael Neumann Changed: lib/dbi/dbi.rb (1.2), "Exp", lines: +852 -138 almost complete rewrite of DBI by Michael Neumann 2001-05-29 11:16 Michael Neumann Added: lib/dbi/row.rb (1.1) lib/dbi/utils.rb (1.1) initial import 2001-05-08 14:05 tag dbd_sybase-0-0-3 2001-05-08 14:05 Rainer Perl Changed: ext/dbd_sybase/dbd_sybase.c (1.2), "Exp", lines: +34 -39 ext/dbd_sybase/doc/HISTORY (1.2), "Exp", lines: +3 -0 ext/dbd_sybase/doc/README (1.2), "Exp", lines: +4 -21 Updated dbd_sybase (now 0.0.3) 2001-05-06 17:59 tag dbd_mysql-0-0-4 2001-05-06 17:59 tag dbd_sybase-0-0-2 2001-05-06 17:59 tag dbi-0-0-4 2001-05-06 17:59 tag start 2001-05-06 17:59 Rainer Perl Changed: LICENSE (1.1.1.1), "Exp", lines: +0 -0 README (1.1.1.1), "Exp", lines: +0 -0 setup.rb (1.1.1.1), "Exp", lines: +0 -0 examples/test1.rb (1.1.1.1), "Exp", lines: +0 -0 ext/PATHCONV (1.1.1.1), "Exp", lines: +0 -0 ext/dbd_sybase/dbd_sybase.c (1.1.1.1), "Exp", lines: +0 -0 ext/dbd_sybase/extconf.rb (1.1.1.1), "Exp", lines: +0 -0 ext/dbd_sybase/doc/HISTORY (1.1.1.1), "Exp", lines: +0 -0 ext/dbd_sybase/doc/README (1.1.1.1), "Exp", lines: +0 -0 lib/PATHCONV (1.1.1.1), "Exp", lines: +0 -0 lib/dbd_mysql/dbd_mysql.rb (1.1.1.1), "Exp", lines: +0 -0 lib/dbd_mysql/doc/HISTORY (1.1.1.1), "Exp", lines: +0 -0 lib/dbd_mysql/doc/README (1.1.1.1), "Exp", lines: +0 -0 lib/dbi/dbi.rb (1.1.1.1), "Exp", lines: +0 -0 Imported sources 2001-05-06 17:59 Rainer Perl Added: LICENSE (1.1) README (1.1) setup.rb (1.1) examples/test1.rb (1.1) ext/PATHCONV (1.1) ext/dbd_sybase/dbd_sybase.c (1.1) ext/dbd_sybase/extconf.rb (1.1) ext/dbd_sybase/doc/HISTORY (1.1) ext/dbd_sybase/doc/README (1.1) lib/PATHCONV (1.1) lib/dbd_mysql/dbd_mysql.rb (1.1) lib/dbd_mysql/doc/HISTORY (1.1) lib/dbd_mysql/doc/README (1.1) lib/dbi/dbi.rb (1.1) Initial revision ruby-dbi-0.4.5/LICENSE000066400000000000000000000026421163267757700142730ustar00rootroot00000000000000(C) 2008 Erik Hollensbe . All rights reserved. Please see "README" for earlier copyrights. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ruby-dbi-0.4.5/README000066400000000000000000000175271163267757700141560ustar00rootroot00000000000000= Description The DBI package is a vendor independent interface for accessing databases. It is similar, but not identical to, Perl's DBI module. = Synopsis require 'dbi' # Connect to a database, old style dbh = DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd') # Insert some rows, use placeholders 1.upto(13) do |i| sql = "insert into simple01 (SongName, SongLength_s) VALUES (?, ?)" dbh.do(sql, "Song #{i}", "#{i*10}") end # Select all rows from simple01 sth = dbh.prepare('select * from simple01') sth.execute # Print out each row while row=sth.fetch do p row end # Close the statement handle when done sth.finish # Don't prepare, just do it! dbh.do('delete from simple01 where internal_id > 10') # And finally, disconnect dbh.disconnect # Same example, but a little more Ruby-ish DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd') do | dbh | sql = "insert into simple01 (SongName, SongLength_s) VALUES (?, ?)" dbh.prepare(sql) do | sth | 1.upto(13) { |i| sth.execute("Song #{i}", "#{i*10}") } end dbh.select_all('select * from simple01') do | row | p row end dbh.do('delete from simple01 where internal_id > 10') end = Prerequisites Ruby 1.8.6 or later is the test target, however you may have success with earlier 1.8.x versions of Ruby. = RubyForge Project General information: http://ruby-dbi.rubyforge.org Project information: http://rubyforge.org/projects/ruby-dbi/ Downloads: http://rubyforge.org/frs/?group_id=234 = Installation There are many database drivers (DBDs) available. You only need to install the DBDs for the database software that you will be using. == Gem setup: gem install dbi # One or more of: gem install dbd-mysql gem install dbd-pg gem install dbd-sqlite3 gem install dbd-sqlite == Without rubygems: ruby setup.rb config ruby setup.rb setup ruby setup.rb install == The bleeding edge: git clone git://hollensbe.org/git/ruby-dbi.git git checkout -b development origin/development Also available at git clone git://github.com/erikh/ruby-dbi.git = Available Database Drivers (DBDs) == DBD::MySQL MySQL Depends on the mysql-ruby package from http://www.tmtm.org/mysql or available from the RAA. == DBD::ODBC ODBC Depends on the ruby-odbc package (0.5 or later, 0.9.3 or later recommended) at http://www.ch-werner.de/rubyodbc or available from the RAA. Works together with unix-odbc. == DBD::OCI8 OCI8 (Oracle) Depends on the the ruby-oci8 package, available on the RAA and RubyForge. == DBD::Pg PostgreSQL Depends on the pg package, available on RubyForge. == DBD::SQLite SQLite (versions 2.x and earlier) Depends on the sqlite-ruby package, available on rubyforge. == DBD::SQLite3 SQLite 3.x Depends on the sqlite3-ruby package, available on rubyforge. = Additional Documentation See the directories doc/* for DBI and DBD specific information. The DBI specification is at doc/DBI_SPEC.rdoc. The DBD specification is at doc/DBD_SPEC.rdoc. = Articles == Tutorial: Using the Ruby DBI Module http://www.kitebird.com/articles/ruby-dbi.html = Applications == dbi The SQL command line interpreter dbi is available in directory bin/. It gets installed by default. = License Copyright (c) 2008 Erik Hollensbe Copyright (c) 2005-2006 Kirk Haines, Francis Hwang, Patrick May and Daniel Berger. Copyright (c) 2001, 2002, 2003, 2004 Michael Neumann and others (see the beginning of each file for copyright holder information). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This is the BSD license which is less restrictive than GNU's GPL (General Public License). = Contributors Pistos Too much to specify. Infinite patience and help. Christopher Maujean Lots of initial help when reviving the project. Jun Mukai Contributed initial SQLite3 DBD. John J. Fox IV Lots of help testing on multiple platforms. Kirk Haines One of the authors of the rewrite effort (January 2006). Francis Hwang One of the authors of the rewrite effort (January 2006). Patrick May One of the authors of the rewrite effort (January 2006). Daniel Berger One of the authors of the rewrite effort (January 2006). Michael Neumann Original author of Ruby/DBI; wrote the DBI and most of the DBDs. Rainer Perl Author of Ruby/DBI 0.0.4 from which many good ideas were taken. Jim Weirich Original author of DBD::Pg. Wrote additional code (e.g. sql.rb, testcases). Gave many helpful hints and comments. Eli Green Implemented DatabaseHandle#columns for Mysql and Pg. Masatoshi SEKI For his version of module BasicQuote in sql.rb. John Gorman For his case insensitive load_driver patch and parameter parser. David Muse For testing the DBD::SQLRelay and for his initial DBD. Jim Menard Extended DBD::Oracle for method columns. Joseph McDonald Fixed bug in DBD::Pg (default values in method columns). Norbert Gawor Fixed bug in DBD::ODBC (method columns) and proxyserver. James F. Hranicky Patch for DBD::Pg (cache PGResult#result in Tuples) which increased performance by a factor around 100. Stephen Davies Added method Statement#fetch_scroll for DBD::Pg. Dave Thomas Several enhancements. Brad Hilton Column coercing patch for DBD::Mysql. Sean Chittenden Originally a co-owner of the project. Submitted several patches and helped with lots of comments. MoonWolf Provided the quote/escape_byte patch for DBD::Pg, DBD::SQLite patch and Database#columns implementation. Further patches. Paul DuBois Fixed typos and formatting. Maintains DBD::Mysql. Tim Bates Bug fixes for Mysql and DBI. Brian Candler Zero-padding date/time/timestamps fix. Florian G. Pflug Discussion and helpful comments/benchmarks about DBD::Pg async_exec vs. exec. Oliver M. Bolzer Patches to support Postgres arrays for DBD::Pg. Stephen R. Veit ruby-db2 and DBD::DB2 enhancements. Dennis Vshivkov DBD::Pg patches Cail Borrell from frontbase.com For the Frontbase DBD and C interface. ruby-dbi-0.4.5/bin/000077500000000000000000000000001163267757700140325ustar00rootroot00000000000000ruby-dbi-0.4.5/bin/dbi000066400000000000000000000301661163267757700145210ustar00rootroot00000000000000#!/usr/bin/env ruby # # Copyright (c) 2001, 2002 Michael Neumann # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL # THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # $Id: sqlsh.rb,v 1.2 2006/01/24 04:20:01 francis Exp $ # begin require 'rubygems' gem 'dbi' rescue LoadError => e end require "dbi" begin require "readline" $use_readline = true rescue LoadError $use_readline = false end require "irb" require "irb/completion" $paging = true $irb_completion = Readline.completion_proc require "getoptlong" class ReadlineControl attr_accessor :keywords def initialize @keywords = [] set_prompt initCompletion end def initCompletion if $use_readline Readline.completion_proc = proc {|str| complete(str) } end end def complete(str) @keywords.grep(/^#{Regexp.escape(str)}/i) end def set_prompt(prompt="> ") @prompt = prompt end def readline if $use_readline Readline.readline(@prompt, true) else print @prompt $stdin.readline end end end class Command def tokens(sql) DBI::SQL::PreparedStatement.tokens(sql) end def readCommand line = "" $rd.set_prompt(PROMPT) begin if $input.nil? # no source file to read from l = $rd.readline else # source file has still data l = $input.gets if l.nil? $input = nil next end end next if l.strip.empty? l = l.chomp + "\n" line << l puts $file + INPUT + l unless $input.nil? $rd.set_prompt(PROMPT_CONT) end until complete?(line) return line.strip end private def complete?(line) line =~ /^\s*\\/ or (tokens(line).last || "") =~ /;\s*$/ end end class Actions ACTIONS = [ [ /^\\q(uit)?\s*$/i, :quit ], [ /^\\h(elp)?\s*$/i, :help ], [ /^\\t(ables)?/i, :tables ], [ /^\\dt/i, :describeTable ], [ /^\\s(elect)?/i, :select ], [ /^\\rb/i, :ruby ], [ /^\\irb/i, :irb ], [ /^\\c(ommit)?\s*$/i, :commit ], [ /^\\r(ollback)?\s*$/i, :rollback ], [ /^\\a(utocommit)?(\s+(on|off)?)?\s*$/i, :autocommit ], [ /^\\i(nput)?/i, :input ], [ /^\\o(utput)?/i, :output ], [ /^\\pl/i, :pageLength ], [ /^\\p/i, :togglePaging ], [ //, :unknownCommand ] ] def dispatchCommand(line) ACTIONS.each do |regexp, action| if line =~ regexp then send(action, $~) return end end end def quit(match) puts puts "BYE" puts begin Conn.disconnect rescue DBI::Error => err puts puts err.message p err.backtrace if $DEBUG puts end exit end def help(match) head = %w(Function Description) rows = [ ["\\h[elp]", "Display this help screen"], ["", ""], ["\\t[ables]", "Display all available tables"], ["\\dt table", "Describe columns of 'table'"], ["\\s[elect] table", "short for SELECT * FROM 'table'"], ["", ""], ["\\c[ommit]", "Commits the current transaction"], ["\\r[ollback]", "Rolls back the current transaction"], ["\\a[utocommit]", "Show current autocommit mode"], ["\\a[utocommit] on|off", "Switch autocommit mode on/off"], ["", ""], ["\\i[nput] filename", "Read and execute lines from 'filename'"], ["\\o[utput]", "Disable output"], ["\\o[utput] filename", "Store SQL statments the user inputs into 'filename'"], ["", ""], ["\\pl n", "Set page length to 'n'"], ["\\p", "Toggle paging"], ["", ""], ["\\rb ...", "Execute the rest of the line as Ruby sourcecode"], ["\\irb", "Execute irb within this context"], ["", ""], ["\\q[uit]", "Quit this program"] ] puts puts "Help: " output_table(head, rows) puts end def tables(match) head = ["Table name"] rows = Conn.tables.collect {|name| [name]} puts puts "Tables: " output_table(head, rows) puts end def describeTable(match) table = match.post_match.strip head = %w(name type_name precision scale default nullable indexed primary unique) rows = Conn.columns(table).collect {|col| head.collect{|a| col[a]} } puts puts "Table '#{table}': " output_table(head, rows) puts end def select(match) executeSQL("SELECT * FROM #{match.post_match};") end def commit(match) Conn.commit puts puts "COMMIT" puts end def rollback(match) Conn.rollback puts puts "ROLLBACK" puts end def autocommit(match) mode = match[3] if mode =~ /on/i Conn['AutoCommit'] = true puts puts "AUTOCOMMIT IS NOW ON" puts elsif mode =~ /off/i Conn['AutoCommit'] = false puts puts "AUTOCOMMIT IS NOW OFF" puts else puts if Conn['AutoCommit'] == true puts "AUTOCOMMIT is currently switched ON" elsif Conn['AutoCommit'] == false puts "AUTOCOMMIT is currently switched OFF" else puts "AUTOCOMMIT is in unknown state" end puts end end def input(match) puts $file = match.post_match.strip begin $input = File.open($file) puts "EXECUTE file #{$file}" puts rescue puts "Couldn't read from file #{$file}" puts end end def output(match) puts file = match.post_match.strip if file.empty? $output.close if $output $output = nil puts "Disabled OUTPUT" puts else begin $output = File.new(file, "w+") puts "Set OUTPUT to file #{file}" puts rescue puts "Couldn't set OUTPUT to file #{file}" puts end end end def togglePaging(match) $paging = !$paging puts "Paging is now " + ($paging ? "on" : "off") + "." end def pageLength(match) puts $page_len = match.post_match.strip.to_i $page_len = DEFAULT_PAGE_LENGTH if $page_len <= 0 puts "New page length is #{$page_len}." puts end def irb(match) Readline.completion_proc = $irb_completion puts puts "================================== IRB ===============================" begin IRB.start rescue SystemExit end puts "======================================================================" $rd.initCompletion end def ruby(match) puts eval match.post_match puts end def unknownCommand(match) puts puts "Unknown command!" puts end end def output_table(header, rows) DBI::Utils::TableFormatter.ascii(header, rows, nil, nil, nil, nil, $page_len) do if $paging print "[enter to continue, a to abort]" break if $stdin.readline.chomp.downcase == "a" end end end def executeSQL(sql) sql = $` if sql =~ /;\s*$/ start = ::Time.now stmt = Conn.execute(sql) head = stmt.column_names # DDL, DCL if head.empty? puts nr = stmt.rows if nr == 0 puts " No rows affected" elsif nr == 1 puts " 1 row affected" else puts " #{nr} rows affected" end puts else rows = stmt.fetch_all tm = ::Time.now - start puts output_table(head, rows || []) print " " if rows.nil? print "No rows in set" elsif rows.size == 1 print "1 row in set" else print "#{rows.size} rows in set" end puts " (#{(tm.to_f*1000).to_i / 1000.0} sec)" puts end $rd.keywords = SQL_KEYWORDS + Conn.tables end DEFAULT_PAGE_LENGTH = 37 $output = nil $input = nil $page_len = DEFAULT_PAGE_LENGTH PROMPT = "dbi => " PROMPT_CONT = "dbi -> " INPUT = " >> " SQL_KEYWORDS = %w( INSERT DELETE UPDATE SELECT FROM WHERE IN LIKE SET VALUES INTO CREATE TABLE DROP COMMIT ROLLBACK CHAR VARCHAR VARCHAR2 INT INTEGER NUMBER FLOAT REAL LONG CLOB BLOB DECIMAL DBCLOB DBBLOB ) # --------------------------------------------------------------------------- opts = GetoptLong.new( ["--file", "-f", GetoptLong::REQUIRED_ARGUMENT ] ) opts.each do |opt, arg| case opt when "--file" $input_file_name = arg end end if ARGV.size < 1 or ARGV.size > 3 puts puts "USAGE: #{$0} [--file file] driver_url [user [password] ]" puts puts "Available driver and datasources:" puts for driver in DBI.available_drivers do puts driver begin ds = DBI.data_sources(driver) for datasource in ds puts " " + datasource end rescue => err end puts end puts exit 1 else DRIVER_URL = ARGV.shift USER = ARGV.shift PASS = ARGV.shift end puts begin Conn = DBI.connect(DRIVER_URL, USER, PASS) print "CONNECT TO #{DRIVER_URL} " print "USER #{USER} " unless USER.nil? print "PASS #{PASS} " unless PASS.nil? print "\n" rescue DBI::Error, DBI::Warning => err p err exit end puts $rd = ReadlineControl.new $rd.keywords = SQL_KEYWORDS + Conn.tables cmd = Command.new act = Actions.new # --file option if $input_file_name def $input_file_name.post_match $input_file_name end act.input($input_file_name) end # Main-Loop ----------------------------------- loop do line = cmd.readCommand $output.puts line unless $output.nil? begin if line =~ /^\\/ then # Internal Command act.dispatchCommand(line) else # SQL Command executeSQL(line) end rescue DBI::Error => err puts puts err.message p err.backtrace if $DEBUG puts end end ruby-dbi-0.4.5/bin/test_broken_dbi000077500000000000000000000012771163267757700171240ustar00rootroot00000000000000#!/usr/bin/env ruby load_path = false gems = false redefined = false # these clauses are for installations which have RUBYOPT=-rubygems, etc. if Object.const_defined? "Gem" redefined = true module Kernel alias gem_require require alias require gem_original_require end end begin require 'dbi' load_path = true rescue LoadError => e end if Object.const_defined? "Gem" and redefined module Kernel alias gem_original_require require alias require gem_require end end begin require 'rubygems' gem 'dbi' gems = true rescue LoadError rescue Gem::LoadError end puts "Your installation of DBI is broken" if gems and load_path ruby-dbi-0.4.5/build/000077500000000000000000000000001163267757700143615ustar00rootroot00000000000000ruby-dbi-0.4.5/build/Rakefile.dbi.rb000066400000000000000000000035411163267757700171700ustar00rootroot00000000000000require 'rake_task_lib' require 'dbi' DBD_PACKAGES = Dir['lib/dbd/*.rb'].collect { |x| File.basename(x, '.rb') } # creates a number of tasks like dbi:task_name, dbd_mysql:task_name, so on. # Builds these out into an array that can be used as a prereq for other tasks. def map_task(task_name) namespaces = (['dbi'] + DBD_PACKAGES.collect { |x| dbd_namespace(x) }).flatten namespaces.collect { |x| [x, task_name].join(":") } end task :package => (map_task("package") + map_task("gem")) task :clobber_package => map_task("clobber_package") desc 'Run interface tests (no database connectivity required)' task :test_dbi do ruby("test/ts_dbi.rb") end desc 'Run database-specific tests' task :test_dbd do ruby("test/ts_dbd.rb") end desc 'Run full test suite' task :test => [:test_dbi, :test_dbd] build_dbi_tasks # # There's probably a better way to do this, but here's a boilerplate spec that we dup and modify. # task :dbi => DEFAULT_TASKS.collect { |x| "dbi:#{x.to_s}" } namespace :dbi do code_files = %w(examples/**/* bin/dbi build/Rakefile.dbi.rb lib/dbi.rb lib/dbi/**/*.rb test/ts_dbi.rb test/dbi/*) spec = boilerplate_spec spec.name = 'dbi' spec.version = DBI::VERSION spec.test_file = 'test/ts_dbi.rb' spec.executables = ['dbi', 'test_broken_dbi'] spec.files = gem_files(code_files) spec.summary = 'A vendor independent interface for accessing databases, similar to Perl\'s DBI' spec.description = 'A vendor independent interface for accessing databases, similar to Perl\'s DBI' spec.add_dependency 'deprecated', '= 2.0.1' build_package_tasks(spec, code_files) end DBD_PACKAGES.each do |dbd| my_namespace = dbd_namespace(dbd) task my_namespace => DEFAULT_TASKS.collect { |x| "#{my_namespace}:#{x.to_s}" } namespace my_namespace do build_dbd_tasks(dbd) end end ruby-dbi-0.4.5/examples/000077500000000000000000000000001163267757700151005ustar00rootroot00000000000000ruby-dbi-0.4.5/examples/test1.pl000066400000000000000000000012041163267757700164720ustar00rootroot00000000000000use DBI; $dbh = DBI->connect("dbi:Oracle:oracle.neumann", "scott", "tiger", {RaiseError => 1, AutoCommit => 0} ); $dbh->do("DROP TABLE MYTEST"); $dbh->do("CREATE TABLE MYTEST (a INT, b VARCHAR2(256), c FLOAT, d VARCHAR2(256))"); $sth = $dbh->prepare("INSERT INTO MYTEST VALUES (:1, :2, :3, :4)"); $i = 1; while ($i <= 10000) { $sth->execute($i, "Michael der $i. von Neumann", 5.6 * $i, "HALLO LEUTE WIE GEHTS DENN SO?"); $i = $i + 1; #print $i, "\n"; } $dbh->commit(); #$sth = $dbh->prepare("SELECT * FROM EMP"); #$sth->execute(); #while (@row = $sth->fetchrow_array()) { # print(@row); #} $dbh->disconnect(); ruby-dbi-0.4.5/examples/test1.rb000066400000000000000000000007231163267757700164670ustar00rootroot00000000000000require "dbi" dbh = DBI.connect("dbi:Oracle:oracle.neumann", "scott", "tiger", 'AutoCommit' => false) dbh.do("DROP TABLE MYTEST") dbh.do("CREATE TABLE MYTEST (a INT, b VARCHAR2(256), c FLOAT, d VARCHAR2(256))") sth = dbh.prepare("INSERT INTO MYTEST VALUES (:1, :2, :3, :4)") 1.upto(10000) do |i| sth.execute(i.to_s, "Michael der #{i}. von Neumann", (5.6 * i).to_s, "HALLO LEUTE WIE GEHTS DENN SO?") #print i, "\n" end sth.finish dbh.commit dbh.disconnect ruby-dbi-0.4.5/examples/xmltest.rb000066400000000000000000000002611163267757700171240ustar00rootroot00000000000000require "dbi" DBI.connect("dbi:Oracle:oracle.neumann") do |dbh| dbh.execute("SELECT * FROM EMP") do |sth| DBI::Utils::XMLFormatter.table(sth.fetch_all, "EMP") end end ruby-dbi-0.4.5/lib/000077500000000000000000000000001163267757700140305ustar00rootroot00000000000000ruby-dbi-0.4.5/lib/dbi.rb000066400000000000000000000316061163267757700151210ustar00rootroot00000000000000$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__)) # # DBI - Database Interface for Ruby. Please see the files README, DBI_SPEC, # DBD_SPEC for more information. # module DBI; end #-- # Ruby/DBI # # Copyright (c) 2001, 2002, 2003 Michael Neumann # Copyright (c) 2008 Erik Hollensbe # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL # THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # begin require "rubygems" gem "deprecated", "= 2.0.1" rescue LoadError end # # NOTE see the end of the file for requires that live in the DBI namespace. # require "deprecated" require "dbi/row" require "dbi/utils" require "dbi/sql" require "dbi/columninfo" require 'dbi/types' require 'dbi/typeutil' require 'dbi/sql_type_constants' require 'dbi/exceptions' require 'dbi/binary' require 'dbi/handles' require 'dbi/base_classes' require "date" require "thread" require 'monitor' class Class # Given a Class, returns if the object's (another Class) ancestors contain # that class. def inherits_from?(klass) self.ancestors.include?(klass) end end Deprecate.set_action( proc do |call| klass, meth = call.split(/[#.]/) klass = klass.split(/::/).inject(Module) { |a,x| a.const_get(x) } case klass when DBI::Date, DBI::Time, DBI::Timestamp warn "DBI::Date/Time/Timestamp are deprecated and will eventually be removed." end if klass.inherits_from?(DBI::ColumnInfo) warn "ColumnInfo methods that do not match a component are deprecated and will eventually be removed" end warn "You may change the result of calling deprecated code via Deprecate.set_action; Trace follows:" warn caller[2..-1].join("\n") end ) #++ module DBI VERSION = "0.4.5" module DBD # :nodoc: API_VERSION = "0.3" end # Module functions (of DBI) DEFAULT_TRACE_MODE = 2 DEFAULT_TRACE_OUTPUT = STDERR # TODO: Is using class variables within a module such a wise idea? - Dan B. @@driver_map = Hash.new @@driver_monitor = ::Monitor.new() @@trace_mode = DEFAULT_TRACE_MODE @@trace_output = DEFAULT_TRACE_OUTPUT @@caseless_driver_name_map = nil @@convert_types = true @@last_connection = nil # Return the last connection attempted. def self.last_connection @@last_connection end # Return the current status of type conversion at this level. This status # will be propogated to any new DatabaseHandles created. def self.convert_types @@convert_types end # Set the current status of type conversion at this level. This status # will be propogated to any new DatabaseHandles created. def self.convert_types=(bool) @@convert_types = bool end class << self # Establish a database connection. # # Format goes as such: "dbi:Driver:database_conn_args" # # * "dbi" is the literal string "dbi". Case is unimportant. # * "Driver" is the case-dependent name of your database driver class. # The file "dbd/#{Driver}" will be required. If you are using rubygems to # control your DBDs and DBI, you must make the gem's file path available # via the "gem" command before this will work. # * database_conn_args can be: # * The database name. # * A more complex key/value association (to indicate host, etc). This # is driver dependent; you should consult your DBD documentation. def connect(driver_url, user=nil, auth=nil, params=nil, &p) dr, db_args = _get_full_driver(driver_url) dh = dr[0] # driver-handle dh.convert_types = @@convert_types @@last_connection = dh.connect(db_args, user, auth, params, &p) end # Load a DBD and returns the DriverHandle object def get_driver(driver_url) #:nodoc: _get_full_driver(driver_url)[0][0] # return DriverHandle end # Extracts the db_args from driver_url and returns the correspondeing # entry of the @@driver_map. def _get_full_driver(driver_url) #:nodoc: db_driver, db_args = parse_url(driver_url) db_driver = load_driver(db_driver) dr = @@driver_map[db_driver] [dr, db_args] end # # Enable tracing mode. Requires that 'dbi/trace' be required before it does anything. # # As of 0.4.0, this mode does not do anything either way, so this currently just # throws an InterfaceError. This issue is expected to be resolved in the next release. # def trace(mode=nil, output=nil) # FIXME trace raise InterfaceError, "the trace module has been removed until it actually works." @@trace_mode = mode || @@trace_mode || DBI::DEFAULT_TRACE_MODE @@trace_output = output || @@trace_output || DBI::DEFAULT_TRACE_OUTPUT end # # Return a list (of String) of the available drivers. # # NOTE:: This is non-functional for gem installations, due to the # nature of how it currently works. A better solution for # this will be provided in DBI 0.6.0. def collect_drivers drivers = { } # FIXME rewrite this to leverage require and be more intelligent path = File.join(File.dirname(__FILE__), "dbd", "*.rb") Dir[path].each do |f| if File.file?(f) driver = File.basename(f, ".rb") drivers[driver] = f end end return drivers end # Returns a list (of String) of the currently available drivers on your system in # 'dbi:driver:' format. # # This currently does not work for rubygems installations, please see # DBI.collect_drivers for reasons. def available_drivers drivers = [] collect_drivers.each do |key, value| drivers.push("dbi:#{key}:") end return drivers end # Attempt to collect the available data sources to the driver, # specified in DBI.connect format. # # The result is heavily dependent on the driver's ability to enumerate # these sources, and results will vary. def data_sources(driver) db_driver, = parse_url(driver) db_driver = load_driver(db_driver) dh = @@driver_map[db_driver][0] dh.data_sources end # # Attempt to disconnect all database handles. If a driver is provided, # disconnections will happen under that scope. Otherwise, all loaded # drivers (and their handles) will be attempted. # def disconnect_all( driver = nil ) if driver.nil? @@driver_map.each {|k,v| v[0].disconnect_all} else db_driver, = parse_url(driver) @@driver_map[db_driver][0].disconnect_all end end private # Given a driver name, locate and load the associated DBD package, # generate a DriverHandle and return it. def load_driver(driver_name) @@driver_monitor.synchronize do unless @@driver_map[driver_name] dc = driver_name.downcase # caseless look for drivers already loaded found = @@driver_map.keys.find {|key| key.downcase == dc} return found if found begin require "dbd/#{driver_name}" rescue LoadError => e1 # see if you can find it in the path unless @@caseless_driver_name_map @@caseless_driver_name_map = { } collect_drivers.each do |key, value| @@caseless_driver_name_map[key.downcase] = value end end begin require @@caseless_driver_name_map[dc] if @@caseless_driver_name_map[dc] rescue LoadError => e2 raise e1.class, "Could not find driver #{driver_name} or #{driver_name.downcase} (error: #{e1.message})" end end # On a filesystem that is not case-sensitive (e.g., HFS+ on Mac OS X), # the initial require attempt that loads the driver may succeed even # though the lettercase of driver_name doesn't match the actual # filename. If that happens, const_get will fail and it become # necessary to look though the list of constants and look for a # caseless match. The result of this match provides the constant # with the proper lettercase -- which can be used to generate the # driver handle. dr = nil dr_error = nil begin dr = DBI::DBD.const_get(driver_name.intern) rescue NameError => dr_error # caseless look for constants to find actual constant dc = driver_name.downcase found = DBI::DBD.constants.find { |e| e.downcase == dc } dr = DBI::DBD.const_get(found.intern) unless found.nil? end # If dr is nil at this point, it means the underlying driver # failed to load. This usually means it's not installed, but # can fail for other reasons. if dr.nil? err = "Unable to load driver '#{driver_name}'" if dr_error err += " (underlying error: #{dr_error.message})" else err += " (BUG: could not determine underlying error)" end raise DBI::InterfaceError, err end dbd_dr = dr::Driver.new drh = DBI::DriverHandle.new(dbd_dr, @@convert_types) drh.driver_name = dr.driver_name # FIXME trace # drh.trace(@@trace_mode, @@trace_output) @@driver_map[driver_name] = [drh, dbd_dr] return driver_name else return driver_name end end rescue LoadError, NameError if $SAFE >= 1 raise InterfaceError, "Could not load driver (#{$!.message}). Note that in SAFE mode >= 1, driver URLs have to be case sensitive!" else raise InterfaceError, "Could not load driver (#{$!.message})" end end # Splits a DBI URL into two components - the database driver name # and the datasource (along with any options, if any) and returns # a two element array, e.g. 'dbi:foo:bar' would return ['foo','bar']. # # A regular expression is used instead of a simple split to validate # the proper format for the URL. If it isn't correct, an Interface # error is raised. def parse_url(driver_url) if driver_url =~ /^(DBI|dbi):([^:]+)(:(.*))$/ [$2, $4] else raise InterfaceError, "Invalid Data Source Name" end end end # self end # module DBI ruby-dbi-0.4.5/lib/dbi/000077500000000000000000000000001163267757700145665ustar00rootroot00000000000000ruby-dbi-0.4.5/lib/dbi/base_classes.rb000066400000000000000000000004071163267757700175430ustar00rootroot00000000000000#-- # Fallback classes for default behavior of DBD driver # must be inherited by the DBD driver classes #++ module DBI class Base #:nodoc: end end require 'dbi/base_classes/driver' require 'dbi/base_classes/database' require 'dbi/base_classes/statement' ruby-dbi-0.4.5/lib/dbi/base_classes/000077500000000000000000000000001163267757700172155ustar00rootroot00000000000000ruby-dbi-0.4.5/lib/dbi/base_classes/database.rb000066400000000000000000000105311163267757700213060ustar00rootroot00000000000000module DBI # Provides the core-level functionality for DatabaseHandles. # # If the method description says "DBD Required", it's the DBD's # responsibility to create this method. # # Required methods unimplemented by the DBD will raise # DBD::NotImplementedError. # # "DBD Optional" methods are methods that do not have a default # implementation but are optional due to the fact that many databases may # not support these features (and emulating them would be prohibitive). # # These methods raise DBI::NotSupportedError. # # Otherwise, DBI will provide a general alternative which should meet the # expectations of the documentation. However, DBDs can override every # method in this class. # class BaseDatabase < Base def initialize(handle, attr) @handle = handle @attr = {} attr.each {|k,v| self[k] = v} end # Disconnect from the database. DBD Required. def disconnect raise NotImplementedError end # Ping the database to ensure the connection is still alive. Boolean # return, true for success. DBD Required. def ping raise NotImplementedError end # Prepare a cached statement, returning a StatementHandle. DBD # Required. def prepare(statement) raise NotImplementedError end # # Return a map of the columns that exist in the provided table name. # DBD Required. # # The result should be an array of DBI::ColumnInfo objects which have, # at minimum, the following fields: # # * name:: the name of the column. # * type:: This is not a field name in itself. You have two options: # * type_name:: The name of the type as returned by the database # * dbi_type:: A DBI::Type-conforming class that can be used to convert to a native type. # * precision:: the precision (generally length) of the column # * scale:: the scale (generally a secondary attribute to precision # that helps indicate length) of the column # def columns(table) raise NotImplementedError end #============================================ # OPTIONAL #============================================ # Schedule a commit to the database immediately. DBD Optional. def commit raise NotSupportedError end # Schedule a rollback to the database immediately. DBD Optional. def rollback raise NotSupportedError end # Return the tables available to the database connection. # # Note:: the basic implementation returns an empty array. def tables [] end # # Execute a statement with the binds provided. Returns the statement # handle unfinished. # # This is roughly equivalent to: # # sth = dbh.prepare("my statement") # sth.execute(my, bind, vars) # def execute(statement, *bindvars) stmt = prepare(statement) stmt.bind_params(*bindvars) stmt.execute stmt end # # Execute and complete the statement with the binds provided. Returns # the row modified count (via BaseStatement#rows). Finishes the # statement handle for you. # # Roughly equivalent to: # # sth = dbh.prepare("my statement") # sth.execute(my, bind, vars) # result = sth.rows # sth.finish # # Returning the value stored in `result`. def do(statement, *bindvars) stmt = execute(statement, *bindvars) res = stmt.rows stmt.finish return res end # # Get an attribute from the DatabaseHandle. These are DBD specific and # embody things like Auto-Commit support for transactional databases. # # DBD Authors:: This messes with @attr directly. # def [](attr) @attr[attr] end # Set an attribute on the DatabaseHandle. DBD Optional. def []=(attr, value) raise NotSupportedError end end # class BaseDatabase end ruby-dbi-0.4.5/lib/dbi/base_classes/driver.rb000066400000000000000000000025711163267757700210420ustar00rootroot00000000000000module DBI # Implements the basic functionality that constitutes a Driver # # Drivers do not have a direct interface exposed to the user; these methods # are mostly for DBD authors. # # As with DBI::BaseDatabase, "DBD Required" and "DBD Optional" will be used # to explain the same requirements. # class BaseDriver < Base def initialize(dbi_version) major, minor = dbi_version.split(".").collect { |x| x.to_i } dbi_major, dbi_minor = DBI::VERSION.split(".").collect { |x| x.to_i } unless major == dbi_major and minor == dbi_minor raise InterfaceError, "Wrong DBD API version used" end end # Connect to the database. DBD Required. def connect(dbname, user, auth, attr) raise NotImplementedError end # Default u/p information in an array. def default_user ['', ''] end # Default attributes to set on the DatabaseHandle. def default_attributes {} end # Return the data sources available to this driver. Returns an empty # array per default. def data_sources [] end # Disconnect all DatabaseHandles. DBD Required. def disconnect_all raise NotImplementedError end end # class BaseDriver end ruby-dbi-0.4.5/lib/dbi/base_classes/statement.rb000066400000000000000000000114171163267757700215520ustar00rootroot00000000000000module DBI # # StatementHandles are used to encapsulate the process of managing a # statement (DDL or DML) and its parameters, sending it to the database, # and gathering any results from the execution of that statement. # # As with the other `Base` classes, the terms "DBD Required" and "DBD # Optional" are defined in DBI::BaseDatabase. # class BaseStatement < Base attr_accessor :raise_error def initialize(attr=nil) @attr = attr || {} end # # Bind a parameter to the statement. DBD Required. # # The parameter number is numeric and indexes starting at 1. This # corresponds to the question marks (?) in the statement from the # left-most part of the statement moving forward. # # The value may be any ruby type. How these are handled is # DBD-dependent, but the vast majority of DBDs will convert these to # string inside the query. # def bind_param(param, value, attribs) raise NotImplementedError end # # Execute the statement with the known binds. DBD Required. # def execute raise NotImplementedError end # # Close the statement and any result cursors. DBD Required. # # Note:: Most implementations will fail miserably if you forget to # finish your statement handles. def finish raise NotImplementedError end # # Fetch the next row in the result set. DBD Required. # # DBI::Row is responsible for formatting the data the DBD provides it. # def fetch raise NotImplementedError end ## # returns result-set column information as array # of hashs, where each hash represents one column. See # BaseDatabase#columns. DBD Required. # def column_info raise NotImplementedError end #============================================ # OPTIONAL #============================================ # # Take a list of bind variables and bind them successively using bind_param. # def bind_params(*bindvars) bindvars.each_with_index {|val,i| bind_param(i+1, val, nil) } self end # # Cancel any result cursors. DBD Optional, but intentionally does not # raise any exception as it's used internally to maintain consistency. # def cancel end # # fetch_scroll is provided with a direction and offset and works # similar to how seek() is used on files. # # The constants available for direction are as follows: # # * SQL_FETCH_NEXT: fetch the next result. # * SQL_FETCH_LAST: fetch the last result, period. # * SQL_FETCH_RELATIVE: fetch the result at the offset. # # Other constants can be used, but if this method is not supplied by # the driver, they will result in a raise of DBI::NotSupportedError. # def fetch_scroll(direction, offset) case direction when SQL_FETCH_NEXT return fetch when SQL_FETCH_LAST last_row = nil while (row=fetch) != nil last_row = row end return last_row when SQL_FETCH_RELATIVE raise NotSupportedError if offset <= 0 row = nil offset.times { row = fetch; break if row.nil? } return row else raise NotSupportedError end end # # fetch x rows. The result is Array of DBI::Row. # def fetch_many(cnt) rows = [] cnt.times do row = fetch break if row.nil? rows << row.dup end if rows.empty? nil else rows end end # # Fetch all available rows. Result is Array of DBI::Row. # def fetch_all rows = [] loop do row = fetch break if row.nil? rows << row.dup end if rows.empty? nil else rows end end # # Get statement attributes. # def [](attr) @attr ||= { } @attr[attr] end # # Set statement attributes. DBD Optional. # def []=(attr, value) raise NotSupportedError end end # class BaseStatement end ruby-dbi-0.4.5/lib/dbi/binary.rb000066400000000000000000000012551163267757700164020ustar00rootroot00000000000000module DBI # # Encapsulates the concept of a CLOB/BLOB, which can then be passed as a # bind via BaseStatement#bind_param. # # This is similar to a DBI::Type class and will eventually find its way # there. # # See #new for usage. class Binary attr_accessor :data # Construct a new DBI::Binary object with the data supplied as string. # This object can then be used in bound variables to represent a CLOB # or BLOB type. def initialize(data) @data = data end # Return the string representation of the DBI::Binary object. def to_s @data end end end ruby-dbi-0.4.5/lib/dbi/columninfo.rb000066400000000000000000000063201163267757700172650ustar00rootroot00000000000000require 'delegate' begin require 'rubygems' gem 'deprecated', "= 2.0.1" rescue LoadError => e end require 'deprecated' module DBI # This represents metadata for columns within a given table, such as the # data type, whether or not the the column is a primary key, etc. # # ColumnInfo is a delegate of Hash, but represents its keys indifferently, # coercing all strings to symbols. It also has ostruct-like features, f.e.: # # h = ColumnInfo.new({ "foo" => "bar" }) # h[:foo] => "bar" # h["foo"] => "bar" # h.foo => "bar" # # All of these forms have assignment forms as well. # class ColumnInfo < DelegateClass(Hash) # Create a new ColumnInfo object. # # If no Hash is provided, one will be created for you. The hash will be # shallow cloned for storage inside the object, and an attempt will be # made to convert all string keys to symbols. # # In the event that both string and symbol keys are provided in the # initial hash, we cannot safely route around collisions and therefore # a TypeError is raised. # def initialize(hash=nil) @hash = hash.dup rescue nil @hash ||= Hash.new # coerce all strings to symbols @hash.each_key do |x| if x.kind_of? String sym = x.to_sym if @hash.has_key? sym raise ::TypeError, "#{self.class.name} may construct from a hash keyed with strings or symbols, but not both" end @hash[sym] = @hash[x] @hash.delete(x) end end super(@hash) end def [](key) @hash[key.to_sym] end def []=(key, value) @hash[key.to_sym] = value end def default() # :nodoc; XXX hack to get around Hash#default method_missing(:default) end def method_missing(sym, value=nil) if sym.to_s =~ /=$/ sym = sym.to_s.sub(/=$/, '').to_sym @hash[sym] = value elsif sym.to_s =~ /\?$/ sym = sym.to_s.sub(/\?$/, '').to_sym @hash[sym] else @hash[sym] end end # Aliases - XXX soon to be deprecated def self.deprecated_alias(target, source) # :nodoc: define_method(target) { |*args| method_missing(source, *args) } deprecate target end deprecated_alias :is_nullable?, :nullable deprecated_alias :can_be_null?, :nullable deprecated_alias :is_indexed?, :indexed deprecated_alias :is_primary?, :primary deprecated_alias :is_unique, :unique deprecated_alias :size, :precision deprecated_alias :size=, :precision= deprecated_alias :length, :precision deprecated_alias :length=, :precision= deprecated_alias :decimal_digits, :scale deprecated_alias :decimal_digits=, :scale= deprecated_alias :default_value, :default deprecated_alias :default_value=, :default= end end ruby-dbi-0.4.5/lib/dbi/exceptions.rb000066400000000000000000000041451163267757700173000ustar00rootroot00000000000000module DBI # Exceptions (borrowed by Python API 2.0) # Base class of all other error exceptions. Use this to catch all DBI # errors. class Error < RuntimeError end # For important warnings like data truncation, etc. class Warning < RuntimeError end # Exception for errors related to the DBI interface rather than the # database itself. class InterfaceError < Error end # Exception raised if the DBD driver has not specified a mandatory method. class NotImplementedError < InterfaceError end # Exception for errors related to the database. class DatabaseError < Error attr_reader :err, :errstr, :state def initialize(errstr="", err=nil, state=nil) super(errstr) @err, @errstr, @state = err, errstr, state end end # Exception for errors due to problems with the processed # data such as division by zero, numeric value out of range, etc. class DataError < DatabaseError end # Exception for errors related to the database's operation which are not # necessarily under the control of the programmer. This includes such # things as unexpected disconnect, datasource name not found, transaction # could not be processed, a memory allocation error occured during # processing, etc. class OperationalError < DatabaseError end # Exception raised when the relational integrity of the database # is affected, e.g. a foreign key check fails. class IntegrityError < DatabaseError end # Exception raised when the database encounters an internal error, # e.g. the cursor is not valid anymore, the transaction is out of sync. class InternalError < DatabaseError end # Exception raised for programming errors, e.g. table not found # or already exists, syntax error in SQL statement, wrong number # of parameters specified, etc. class ProgrammingError < DatabaseError end # Exception raised if e.g. commit() is called for a database which do not # support transactions. class NotSupportedError < DatabaseError end end ruby-dbi-0.4.5/lib/dbi/handles.rb000066400000000000000000000030411163267757700165270ustar00rootroot00000000000000# # Dispatch classes (Handle, DriverHandle, DatabaseHandle and StatementHandle) # module DBI # # Base class for all handles. # class Handle attr_reader :trace_mode, :trace_output attr_reader :handle attr :convert_types, true def initialize(handle, convert_types=true) @handle = handle @trace_mode = @trace_output = nil @convert_types = convert_types end # Please seee DBI.trace. def trace(mode=nil, output=nil) # FIXME trace raise InterfaceError, "the trace module has been removed until it actually works." @trace_mode = mode || @trace_mode || DBI::DEFAULT_TRACE_MODE @trace_output = output || @trace_output || DBI::DEFAULT_TRACE_OUTPUT end # # Leverage a driver-specific method. The method name will have "__" # prepended to them before calling, and the DBD must define them as # such for them to work. # def func(function, *values) if @handle.respond_to?("__" + function.to_s) then @handle.send("__" + function.to_s, *values) else raise InterfaceError, "Driver specific function <#{function}> not available." end rescue ArgumentError raise InterfaceError, "Wrong # of arguments for driver specific function" end # error functions? end end require 'dbi/handles/driver' require 'dbi/handles/database' require 'dbi/handles/statement' ruby-dbi-0.4.5/lib/dbi/handles/000077500000000000000000000000001163267757700162045ustar00rootroot00000000000000ruby-dbi-0.4.5/lib/dbi/handles/database.rb000066400000000000000000000156421163267757700203050ustar00rootroot00000000000000module DBI # DatabaseHandle is the interface the consumer sees after connecting to the # database via DBI.connect. # # It is strongly discouraged that DBDs inherit from this class directly; # please inherit from the DBI::BaseDatabase instead. # # Note: almost all methods in this class will raise InterfaceError if the # database is not connected. class DatabaseHandle < Handle attr_accessor :last_statement attr_accessor :raise_error # This is the driver name as supplied by the DBD's driver_name method. # Its primary utility is in DBI::TypeUtil#convert. def driver_name return @driver_name.dup if @driver_name return nil end # Assign the driver name. This can be leveraged to create custom type # management via DBI::TypeUtil#convert. def driver_name=(name) @driver_name = name @driver_name.freeze end # # Boolean if we are still connected to the database. See #ping. # def connected? not @handle.nil? end # # Disconnect from the database. Will raise InterfaceError if this was # already done prior. # def disconnect sanity_check @handle.disconnect @handle = nil end # # Prepare a StatementHandle and return it. If given a block, it will # supply that StatementHandle as the first argument to the block, and # BaseStatement#finish it when the block is done executing. # def prepare(stmt) sanity_check(stmt) @last_statement = stmt sth = StatementHandle.new(@handle.prepare(stmt), false, true, @convert_types) # FIXME trace sth.trace(@trace_mode, @trace_output) sth.dbh = self sth.raise_error = raise_error if block_given? begin yield sth ensure sth.finish unless sth.finished? end else return sth end end # # Prepare and execute a statement. It has block semantics equivalent to #prepare. # def execute(stmt, *bindvars) sanity_check(stmt) @last_statement = stmt if @convert_types bindvars = DBI::Utils::ConvParam.conv_param(driver_name, *bindvars) end sth = StatementHandle.new(@handle.execute(stmt, *bindvars), true, true, @convert_types, true) # FIXME trace sth.trace(@trace_mode, @trace_output) sth.dbh = self sth.raise_error = raise_error if block_given? begin yield sth ensure sth.finish unless sth.finished? end else return sth end end # # Perform a statement. This goes straight to the DBD's implementation # of #do (and consequently, BaseDatabase#do), and does not work like # #execute and #prepare. Should return a row modified count. # def do(stmt, *bindvars) sanity_check(stmt) @last_statement = stmt @handle.do(stmt, *DBI::Utils::ConvParam.conv_param(driver_name, *bindvars)) end # # Executes a statement and returns the first row from the result. # def select_one(stmt, *bindvars) sanity_check(stmt) row = nil execute(stmt, *bindvars) do |sth| row = sth.fetch end row end # # Executes a statement and returns all rows from the result. If a block # is given, it is executed for each row. # def select_all(stmt, *bindvars, &p) sanity_check(stmt) rows = nil execute(stmt, *bindvars) do |sth| if block_given? sth.each(&p) else rows = sth.fetch_all end end return rows end # # Return the name of the database we are connected to. # def database_name sanity_check @handle.database_name end # # Return the tables available to this DatabaseHandle as an array of strings. # def tables sanity_check @handle.tables end # # Returns the columns of the provided table as an array of ColumnInfo # objects. See BaseDatabase#columns for the minimum parameters that # this method must provide. # def columns( table ) sanity_check @handle.columns( table ).collect {|col| ColumnInfo.new(col) } end # # Attempt to establish if the database is still connected. While # #connected? returns the state the DatabaseHandle thinks is true, this # is an active operation that will contact the database. # def ping sanity_check @handle.ping end # # Attempt to escape the value, rendering it suitable for inclusion in a SQL statement. # def quote(value) sanity_check @handle.quote(value) end # # Force a commit to the database immediately. # def commit sanity_check @handle.commit end # # Force a rollback to the database immediately. # def rollback sanity_check @handle.rollback end # # Commits, runs the block provided, yielding the DatabaseHandle as it's # argument. If an exception is raised through the block, rollback occurs. # Otherwise, commit occurs. # def transaction sanity_check raise InterfaceError, "No block given" unless block_given? commit begin yield self commit rescue Exception rollback raise end end # Get an attribute from the DatabaseHandle. def [] (attr) sanity_check @handle[attr] end # Set an attribute on the DatabaseHandle. def []= (attr, val) sanity_check @handle[attr] = val end protected def sanity_check(stmt=nil) raise InterfaceError, "Database connection was already closed!" if @handle.nil? check_statement(stmt) if stmt end # basic sanity checks for statements def check_statement(stmt) raise InterfaceError, "Statement is empty, or contains nothing but whitespace" if stmt !~ /\S/ end end end ruby-dbi-0.4.5/lib/dbi/handles/driver.rb000066400000000000000000000035741163267757700200350ustar00rootroot00000000000000module DBI # DriverHandles, while not directly exposed, are essentially the backend # for the facade that many DBI root-level methods communicate with. class DriverHandle < Handle attr_writer :driver_name # Connect to the database. The DSN will have been parsed at this point # and the named parameters should need no explanation. # # If a block is provided to DBI.connect, the connected DatabaseHandle # will be provided as the first argument to the block, and the # DatabaseHandle will be disconnected upon block exit. # def connect(db_args, user, auth, params) user = @handle.default_user[0] if user.nil? auth = @handle.default_user[1] if auth.nil? # TODO: what if only one of them is nil? #if user.nil? and auth.nil? then # user, auth = @handle.default_user #end params ||= {} new_params = @handle.default_attributes params.each {|k,v| new_params[k] = v} if params.has_key?(:_convert_types) @convert_types = params[:_convert_types] end db = @handle.connect(db_args, user, auth, new_params) dbh = DatabaseHandle.new(db, @convert_types) # FIXME trace # dbh.trace(@trace_mode, @trace_output) dbh.driver_name = @driver_name if block_given? begin yield dbh ensure dbh.disconnect if dbh.connected? end else return dbh end end # See BaseDriver#data_sources. def data_sources @handle.data_sources end # See BaseDriver#disconnect_all. def disconnect_all @handle.disconnect_all end end end ruby-dbi-0.4.5/lib/dbi/handles/statement.rb000066400000000000000000000304521163267757700205410ustar00rootroot00000000000000module DBI # # StatementHandle is the interface the consumer sees after successfully # issuing a DatabaseHandle#prepare. They may also be exposed through other # methods that send statements to the database. # # Almost all methods in this class will raise InterfaceError if the # statement is already finished. # class StatementHandle < Handle include Enumerable attr_accessor :dbh attr_accessor :raise_error def initialize(handle, fetchable=false, prepared=true, convert_types=true, executed=false) super(handle) @fetchable = fetchable @prepared = prepared # only false if immediate execute was used @executed = executed # only true if the statement was already executed. @cols = nil @coltypes = nil @convert_types = convert_types if @fetchable @row = DBI::Row.new(column_names, column_types, nil, @convert_types) else @row = nil end end # Returns true if the StatementHandle has had #finish called on it, # explicitly or otherwise. def finished? @handle.nil? end # Returns true if the statement is believed to return data upon #fetch. # # The current reliability of this (and the concept in general) is # suspect. def fetchable? @fetchable end # # Instruct successive calls to #fetch to cast the type returned into # `type`, for row position `pos`. Like all bind_* calls, `pos` indexes # starting at 1. # # `type` is an object with the DBI::Type calling convention. # # This call must be called after #execute has successfully ran, # otherwise it will raise InterfaceError. # # Example: # # `foo` is an integer and this statement will return two rows. # sth = dbh.prepare("select foo from bar") # # would raise InterfaceError if called here # sth.execute # # sth.bind_coltype(1, DBI::Type::Varchar) # # would normally use DBI::Type::Integer and return a Fixnum. We'll make it a string. # sth.fetch => ["1"] # # # Here we coerce it to Float. # sth.bind_coltype(1, DBI::Type::Float) # sth.fetch => [1.0] # sth.finish # def bind_coltype(pos, type) sanity_check({:prepared => true, :executed => true}) coltypes = column_types if (pos - 1) < 0 raise InterfaceError, "bind positions index starting at 1" end coltypes[pos-1] = type @row = DBI::Row.new(column_names, coltypes, nil, @convert_types) end # # Just like BaseStatement#bind_param, but will attempt to convert the # type if it's supposed to, adhering to the DBD's current ruleset. # def bind_param(param, value, attribs=nil) sanity_check({ :prepared => true }) if @convert_types value = DBI::Utils::ConvParam.conv_param(dbh.driver_name, value)[0] end @handle.bind_param(param, value, attribs) end # Execute the statement. # # This generally means that the statement will be sent to the database # and some form of result cursor will be obtained, but is ultimately # driver-dependent. # # If arguments are supplied, these are fed to #bind_param. def execute(*bindvars) cancel # cancel before sanity_check({:prepared => true }) if @convert_types bindvars = DBI::Utils::ConvParam.conv_param(dbh.driver_name, *bindvars) end @handle.bind_params(*bindvars) @handle.execute @fetchable = true @executed = true # TODO:? #if @row.nil? @row = DBI::Row.new(column_names, column_types, nil, @convert_types) #end return nil end # # Finish the statement, causing the database to release all assets # related to it (any result cursors, normally). # # StatementHandles that have already been finished will normally be # inoperable and unavailable for further use. # def finish sanity_check @handle.finish @handle = nil end # # Cancel the query, closing any open result cursors and truncating any result sets. # # The difference between this and #finish is that cancelled statements # may be re-executed. # def cancel sanity_check @handle.cancel if @fetchable @fetchable = false end # # Obtains the column names for this query as an array. # def column_names sanity_check return @cols unless @cols.nil? @cols = @handle.column_info.collect {|col| col['name'] } end # # Obtain the type mappings for the columns in this query based on # ColumnInfo data on the query. # # The result will be a position-dependent array of objects that conform # to the DBI::Type calling syntax. # def column_types sanity_check return @coltypes unless @coltypes.nil? @coltypes = @handle.column_info.collect do |col| if col['dbi_type'] col['dbi_type'] else DBI::TypeUtil.type_name_to_module(col['type_name']) end end end # # See BaseStatement#column_info. # def column_info sanity_check @handle.column_info.collect {|col| ColumnInfo.new(col) } end # # Should return the row modified count as the result of statement execution. # # However, some low-level drivers do not supply this information or # supply misleading information (> 0 rows for read-only select # statements, f.e.) # def rows sanity_check @handle.rows end # # See BaseStatement#fetch. # # fetch can also take a block which will be applied to each row in a # similar fashion to Enumerable#collect. See #each. # def fetch(&p) sanity_check({ :fetchable => true, :prepared => true, :executed => true }) if block_given? while (res = @handle.fetch) != nil @row = @row.dup @row.set_values(res) yield @row end @handle.cancel @fetchable = false return nil else res = @handle.fetch if res.nil? @handle.cancel @fetchable = false else @row = @row.dup @row.set_values(res) res = @row end return res end end # # Synonym for #fetch with a block. # def each(&p) sanity_check({:fetchable => true, :prepared => true, :executed => true}) raise InterfaceError, "No block given" unless block_given? fetch(&p) end # # Similar to #fetch, but returns Array of Array instead of Array of # DBI::Row objects (and therefore does not perform type mapping). This # is basically a way to get the raw data from the DBD. # def fetch_array sanity_check({:fetchable => true, :prepared => true, :executed => true}) if block_given? while (res = @handle.fetch) != nil yield res end @handle.cancel @fetchable = false return nil else res = @handle.fetch if res.nil? @handle.cancel @fetchable = false end return res end end # # Map the columns and results into an Array of Hash resultset. # # No type conversion is performed here. Expect this to change in 0.6.0. # def fetch_hash sanity_check({:fetchable => true, :prepared => true, :executed => true}) cols = column_names if block_given? while (row = @handle.fetch) != nil hash = {} row.each_with_index {|v,i| hash[cols[i]] = v} yield hash end @handle.cancel @fetchable = false return nil else row = @handle.fetch if row.nil? @handle.cancel @fetchable = false return nil else hash = {} row.each_with_index {|v,i| hash[cols[i]] = v} return hash end end end # # Fetch `cnt` rows. Result is array of DBI::Row # def fetch_many(cnt) sanity_check({:fetchable => true, :prepared => true, :executed => true}) cols = column_names rows = @handle.fetch_many(cnt) if rows.nil? or rows.empty? @handle.cancel @fetchable = false return [] else return rows.collect{|r| tmp = @row.dup; tmp.set_values(r); tmp } end end # # Fetch the entire result set. Result is array of DBI::Row. # def fetch_all sanity_check({:fetchable => true, :prepared => true, :executed => true}) cols = column_names fetched_rows = [] begin while row = fetch do fetched_rows.push(row) end rescue Exception end @handle.cancel @fetchable = false return fetched_rows end # # See BaseStatement#fetch_scroll. # def fetch_scroll(direction, offset=1) sanity_check({:fetchable => true, :prepared => true, :executed => true}) row = @handle.fetch_scroll(direction, offset) if row.nil? #@handle.cancel #@fetchable = false return nil else @row.set_values(row) return @row end end # Get an attribute from the StatementHandle object. def [] (attr) sanity_check @handle[attr] end # Set an attribute on the StatementHandle object. def []= (attr, val) sanity_check @handle[attr] = val end protected def sanity_check(params={}) raise InterfaceError, "Statement was already closed!" if @handle.nil? params.each_key do |key| case key when :fetchable check_fetchable when :executed check_executed when :prepared check_prepared when :statement check_statement(params[:statement]) end end end def check_prepared raise InterfaceError, "Statement wasn't prepared before." unless @prepared end def check_fetchable if !@fetchable and @raise_error raise InterfaceError, "Statement does not have any data for fetching." end end def check_executed raise InterfaceError, "Statement hasn't been executed yet." unless @executed end # basic sanity checks for statements def check_statement(stmt) raise InterfaceError, "Statement is empty, or contains nothing but whitespace" if stmt !~ /\S/ end end # class StatementHandle end ruby-dbi-0.4.5/lib/dbi/row.rb000066400000000000000000000227541163267757700157340ustar00rootroot00000000000000require "delegate" module DBI # DBI::Row is the representation of a row in a result set returned by the # database. # # It is responsible for containing and representing the result set, converting # it to native Ruby types, and providing methods to sanely move through itself. # # The DBI::Row class is a delegate of Array, rather than a subclass, because # there are times when it should act like an Array, and others when it should # act like a Hash (and still others where it should act like String, Regexp, # etc). It also needs to store metadata about the row, such as # column data type and index information, that users can then access. # class Row < DelegateClass(Array) attr_reader :column_names # DBI::Row.new(columns, column_types, size_or_array=nil) # # Returns a new DBI::Row object using +columns+. The +size_or_array+ # argument may either be an Integer or an Array. If it is not provided, # it defaults to the length of +columns+. # # Column types is a corresponding Array of Class/Module objects that # conform to the DBI::Type interface. These will be used to convert types # as they are returned. # # DBI::Row is a delegate of the Array class, so all of the Array # instance methods are available to your DBI::Row object (keeping in # mind that initialize, [], and []= have been explicitly overridden). # def initialize(columns, column_types, size_or_array=nil, convert_types=true) @column_types = column_types @convert_types = convert_types size_or_array ||= columns.size # The '@column_map' is used to map column names to integer values so # that users can reference row values by name or number. @column_map = {} @column_names = columns columns.each_with_index { |c,i| @column_map[c] = i } case size_or_array when Integer super(@arr = Array.new(size_or_array)) when Array super(@arr = size_or_array.dup) set_values(size_or_array.dup) else raise TypeError, "parameter must be either Integer or Array" end end # converts the types in the array to their specified representation # from column types provided at construction time. def convert_types(arr) return arr.dup unless @convert_types if arr.size != @column_types.size raise TypeError, "Type mapping is not consistent with result" end new_arr = [] arr.each_with_index do |item, i| new_arr.push((@column_types[i] || DBI::Type::Varchar).parse(item)) end return new_arr end # Replaces the contents of the internal array with +new_values+. # elements are type converted at this time. def set_values(new_values) @arr.replace(convert_types(new_values)) end # Yields a column value by name (rather than index), along with the # column name itself. def each_with_name @arr.each_with_index do |v, i| yield v, @column_names[i] end end # returns the underlying array (duplicated) def to_a @arr.dup end # Returns the Row object as a hash, created by #each_with_name. def to_h hash = {} each_with_name{ |v, n| hash[n] = v} hash end # Create a new row with 'new_values', reusing the field name hash. # Initial cloning is done deeply, via Marshal. def clone_with(new_values) obj = clone obj.set_values(new_values) return obj end alias field_names column_names # Retrieve a value by index (rather than name). # # Deprecated. Since Row delegates to Array, just use Row#at. def by_index(index) @arr[index] end # Value of the field named +field_name+ or nil if not found. def by_field(field_name) begin @arr[@column_map[field_name.to_s]] rescue TypeError nil end end # Row#[] # # row[int] # row[array] # row[regexp] # row[arg, arg] # row[arg, arg, ...] # # Sample: Row.new(["first","last","age"], ["Daniel", "Berger", "36"]) # # Retrieves row elements. Exactly what it retrieves depends on the # kind and number of arguments used. # # Zero arguments will raise an ArgumentError. # # One argument will return a single result. This can be a String, # Symbol, Integer, Range or Regexp and the appropriate result will # be returned. Strings, Symbols and Regexps act like hash lookups, # while Integers and Ranges act like Array index lookups. # # Two arguments will act like the second form of Array#[], i.e it takes # two integers, with the first number the starting point and the second # number the length, and returns an array of values. # # If three or more arguments are provided, an array of results is # returned. The behavior for each argument is that of a single argument, # i.e. Strings, Symbols, and Regexps act like hash lookups, while # Integers and Ranges act like Array index lookups. # # If no results are found, or an unhandled type is passed, then nil # (or a nil element) is returned. # def [](*args) begin case args.length when 0 err = "wrong # of arguments(#{args.size} for at least 1)" raise ArgumentError, err when 1 case args[0] when Array args[0].collect { |e| self[e] } when Regexp self[@column_names.grep(args[0])] else @arr[conv_param(args[0])] end # We explicitly check for a length of 2 in order to properly # simulate the second form of Array#[]. when 2 @arr[conv_param(args[0]), conv_param(args[1])] else results = [] args.flatten.each{ |arg| case arg when Integer results.push(@arr[arg]) when Regexp results.push(self[@column_names.grep(arg)]) else results.push(self[conv_param(arg)]) end } results.flatten end rescue TypeError nil end end # Assign a value to a Row object by element. You can assign using # a single element reference, or by using a start and length similar # to the second form of Array#[]=. # # row[0] = "kirk" # row[:last] = "haines" # row[0, 2] = "test" # def []=(key, value_or_length, obj=nil) if obj @arr[conv_param(key), conv_param(value_or_length)] = obj else @arr[conv_param(key)] = value_or_length end end if RUBY_VERSION =~ /^1\.9/ def __getobj__ @arr end def __setobj__(obj) @delegate_dc_obj = @arr = obj end else # # See Object#clone. # # #clone and #dup here, however, are both deep copies via Marshal. # def clone Marshal.load(Marshal.dump(self)) end def dup row = self.class.allocate row.instance_variable_set :@column_types, @column_types row.instance_variable_set :@convert_types, @convert_types row.instance_variable_set :@column_map, @column_map row.instance_variable_set :@column_names, @column_names # this is the only one we actually dup... row.instance_variable_set :@arr, arr = @arr.dup row.instance_variable_set :@_dc_obj, arr row end end private # Simple helper method to grab the proper value from @column_map # NOTE this does something completely different than DBI::Utils::ConvParam def conv_param(arg) # :nodoc: case arg when String, Symbol @column_map[arg.to_s] when Range if arg.first.kind_of?(Symbol) || arg.first.kind_of?(String) first = @column_map[arg.first.to_s] last = @column_map[arg.last.to_s] else first = arg.first last = arg.last end if arg.exclude_end? (first...last) else (first..last) end else arg end end end # class Row end # module DBI ruby-dbi-0.4.5/lib/dbi/sql.rb000066400000000000000000000010431163267757700157100ustar00rootroot00000000000000# # $Id: sql.rb,v 1.3 2006/03/27 20:25:02 francis Exp $ # # parts extracted from Jim Weirichs DBD::Pg # require "dbi/utils" require "time" module DBI # the SQL package contains assistance for DBDs and generally will not be # needed outside of them. module SQL # Helper to determine if the statement is a query. Very crude and # should not be relied on for accuracy. def self.query?(sql) sql =~ /^\s*select\b/i end end # module SQL end # module DBI require 'dbi/sql/preparedstatement' ruby-dbi-0.4.5/lib/dbi/sql/000077500000000000000000000000001163267757700153655ustar00rootroot00000000000000ruby-dbi-0.4.5/lib/dbi/sql/preparedstatement.rb000066400000000000000000000105241163267757700214430ustar00rootroot00000000000000module DBI module SQL # # The PreparedStatement class attempts to provide binding functionality # for database systems that do not have this built-in. This package # emulates the whole concept of a statement. # class PreparedStatement attr_accessor :unbound # Convenience method for consumers that just need the tokens # method. def self.tokens(sql) self.new(nil, sql).tokens end # # "prepare" a statement. # # +quoter+ is deprecated and will eventually disappear, it is kept # currently for compatibility. It is safe to pass nil to this parameter. # # +sql+ is the statement itself. # def initialize(quoter, sql) @quoter, @sql = quoter, sql prepare end # Break the sql string into parts. # # This is NOT a full lexer for SQL. It just breaks up the SQL # string enough so that question marks, double question marks and # quoted strings are separated. This is used when binding # arguments to "?" in the SQL string. # # C-style (/* */) and Ada-style (--) comments are handled. # Note:: Nested C-style comments are NOT handled! # def tokens @sql.scan(%r{ ( -- .* (?# matches "--" style comments to the end of line or string ) | - (?# matches single "-" ) | /[*] .*? [*]/ (?# matches C-style comments ) | / (?# matches single slash ) | ' ( [^'\\] | '' | \\. )* ' (?# match strings surrounded by apostophes ) | " ( [^"\\] | "" | \\. )* " (?# match strings surrounded by " ) | \?\?? (?# match one or two question marks ) | [^-/'"?]+ (?# match all characters except ' " ? - and / ) )}x).collect {|t| t.first} end # attempts to bind the arguments in +args+ to this statement. # Will raise StandardError if there are any extents issues. def bind(args) if @arg_index < args.size raise "Too many SQL parameters" elsif @arg_index > args.size raise "Not enough SQL parameters" end @unbound.each do |res_pos, arg_pos| @result[res_pos] = args[arg_pos] end @result.join("") end private # prepares the statement for binding. This is done by scanning the # statement and itemizing what needs to be bound and what does not. # # This information will then be used by #bind to appropriately map # parameters to the intended destinations. def prepare @result = [] @unbound = {} pos = 0 @arg_index = 0 tokens.each { |part| case part when '?' @result[pos] = nil @unbound[pos] = @arg_index pos += 1 @arg_index += 1 when '??' if @result[pos-1] != nil @result[pos-1] << "?" else @result[pos] = "?" pos += 1 end else if @result[pos-1] != nil @result[pos-1] << part else @result[pos] = part pos += 1 end end } end end # PreparedStatement end end ruby-dbi-0.4.5/lib/dbi/sql_type_constants.rb000066400000000000000000000037671163267757700210640ustar00rootroot00000000000000module DBI # Constants # Constants for fetch_scroll # SQL_FETCH_NEXT = 1 SQL_FETCH_PRIOR = 2 SQL_FETCH_FIRST = 3 SQL_FETCH_LAST = 4 SQL_FETCH_ABSOLUTE = 5 SQL_FETCH_RELATIVE = 6 # SQL type constants # SQL_CHAR = 1 SQL_NUMERIC = 2 SQL_DECIMAL = 3 SQL_INTEGER = 4 SQL_SMALLINT = 5 SQL_FLOAT = 6 SQL_REAL = 7 SQL_DOUBLE = 8 SQL_DATE = 9 # 91 SQL_TIME = 10 # 92 SQL_TIMESTAMP = 11 # 93 SQL_VARCHAR = 12 SQL_BOOLEAN = 13 SQL_LONGVARCHAR = -1 SQL_BINARY = -2 SQL_VARBINARY = -3 SQL_LONGVARBINARY = -4 SQL_BIGINT = -5 SQL_TINYINT = -6 SQL_BIT = -7 # TODO # Find types for these (XOPEN?) #SQL_ARRAY = SQL_BLOB = -10 # TODO SQL_CLOB = -11 # TODO #SQL_DISTINCT = #SQL_OBJECT = #SQL_NULL = SQL_OTHER = 100 #SQL_REF = #SQL_STRUCT = SQL_TYPE_NAMES = { SQL_BIT => 'BIT', SQL_TINYINT => 'TINYINT', SQL_SMALLINT => 'SMALLINT', SQL_INTEGER => 'INTEGER', SQL_BIGINT => 'BIGINT', SQL_FLOAT => 'FLOAT', SQL_REAL => 'REAL', SQL_DOUBLE => 'DOUBLE', SQL_NUMERIC => 'NUMERIC', SQL_DECIMAL => 'DECIMAL', SQL_CHAR => 'CHAR', SQL_VARCHAR => 'VARCHAR', SQL_LONGVARCHAR => 'LONG VARCHAR', SQL_DATE => 'DATE', SQL_TIME => 'TIME', SQL_TIMESTAMP => 'TIMESTAMP', SQL_BINARY => 'BINARY', SQL_VARBINARY => 'VARBINARY', SQL_LONGVARBINARY => 'LONG VARBINARY', SQL_BLOB => 'BLOB', SQL_CLOB => 'CLOB', SQL_OTHER => nil, SQL_BOOLEAN => 'BOOLEAN', } end ruby-dbi-0.4.5/lib/dbi/trace.rb000066400000000000000000000056151163267757700162200ustar00rootroot00000000000000# $Id: trace.rb,v 1.1 2006/01/04 02:03:22 francis Exp $ # # Tracing for DBI programs # # Copyright (c) 2001 Michael Neumann # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. raise LoadError, "the trace module has been removed until it actually works." # works only correct with the newest version > 0.3.3 require "aspectr" require "dbi" # to work as "ruby -r dbi/trace myapp.rb" module DBI class HandleTracer < AspectR::Aspect def initialize(klass) @never_wrap = /^__|^send$|^id$|^class$|^$ / self.wrap(klass, :pre, :post, methods(klass)) end # trace methods -------------------------------------------------------------- def pre(method, object, exitstatus, *args) par = args.collect{|a| a.inspect}.join(", ") if object.trace_mode == 2 then object.trace_output << "-> #{method} for #{object} (#{par})\n" elsif object.trace_mode == 3 then object.trace_output << "-> #{method} for #{object.inspect} (#{par})\n" end end def post(method, object, exitstatus, *args) case object.trace_mode when 1, 2 # return values and errors arrow = object.trace_mode == 1 ? "<=" : "<-" if exitstatus.kind_of? Array object.trace_output << "#{arrow} #{method} for #{object} = #{exitstatus[0] || 'nil'}\n" else if exitstatus == true object.trace_output << "!! #{$!.message.chomp}\n" end object.trace_output << "#{arrow} #{method} for #{object}\n" end when 3 if exitstatus.kind_of? Array object.trace_output << "<- #{method} for #{object.inspect} = #{exitstatus[0].inspect}\n" else if exitstatus == true object.trace_output << "!! #{$!.inspect}\n" end object.trace_output << "<- #{method} for #{object.inspect}\n" end end end private # helper methods ----------------------------------------------------- def methods(klass) meths = (DBI::Handle.instance_methods | klass.instance_methods) - %w(trace_mode trace_output trace) /(#{meths.collect{|m| Regexp.quote(m)}.join('|')})/ end end @@tracer_driver = HandleTracer.new(DBI::DriverHandle) @@tracer_database = HandleTracer.new(DBI::DatabaseHandle) @@tracer_statement = HandleTracer.new(DBI::StatementHandle) end # module DBI ruby-dbi-0.4.5/lib/dbi/types.rb000066400000000000000000000203061163267757700162600ustar00rootroot00000000000000require 'time' require 'bigdecimal' require 'rational' module DBI # # Interface to convert SQL result sets to native Ruby types. # # Type is used to convert result sets, which differ from bound variables # (which generally go in the opposite direction). For those, see # DBI::TypeUtil#convert and DBI::TypeUtil#register_conversion. # # Type objects have a simple interface: they implement a +parse+ method # which takes the result from the DBD and attempts to convert it to the # native type. In the event that they do not do this successfully, they are # expected to return the object in its original form. # # As a result, many of the built-in Type classes fallback to simpler forms: # Float falls back to Integer, Integer to Varchar, etc. It's questionable # at this point if it's desirable to do this, but testing has so far proven # it a non-issue. # # To reiterate, it is *never acceptable* to return +nil+ or some other # placeholder when an object will not successfully parse. Return the object # handed to you. # # Types must also handle +nil+ as a result to parse. In this case, the # advisable solution is to just let the +nil+ pass through, as it's usually # indicative of a SQL NULL result. # # DBI::Row handles delegation of these objects as a converter for the # results. Typically, the type object is a class inferred from # DBI::TypeUtil#type_name_to_module ran against the ColumnInfo field # +type_name+. However, the the +dbi_type+ field can be used in its place # to directly associate a Type object with the column in the DBD, and # end-users can leverage StatementHandle#bind_coltype to manually tweak # this transformation. # # As stated before, Type objects are objects. These objects may be Modules # or Classes (and typically are), but there is no reason a traditional # constructed object with a +parse+ method cannot be returned; in fact, it # is used in a few spots to emulate complex types such as PostgreSQL # arrays. Look into the +dbi_type+ ColumnInfo field to pass these types # around. # module Type # # Represents a SQL NULL. # class Null def self.parse(obj) return nil if obj.to_s.match(/^null$/i) return obj end end # # Represents a SQL char or varchar. General fallback class. # class Varchar def self.parse(obj) return obj unless obj return obj.to_s if obj.respond_to? :to_s return obj.to_str if obj.respond_to? :to_str return obj end end # # Represents a whole number. Falls back to Varchar. # class Integer < Varchar def self.parse(obj) return nil if Null.parse(obj).nil? return obj.to_i if obj.respond_to? :to_i super end end # # Represents a decimal number with floating-point precision. Falls back # to Integer. # class Float < Integer def self.parse(obj) return nil if Null.parse(obj).nil? return obj.to_f if obj.respond_to? :to_f super end end # # Represents a Decimal with real precision (BigDecimal). Falls back to # Float. # class Decimal < Float def self.parse(obj) BigDecimal.new(obj) rescue super end end # # Represents a SQL TIMESTAMP and returns DateTime. Falls back to Null. # class Timestamp < Null def self.create(year, month, day, hour, min, sec, usec=0, of=0) # DateTime will remove leap and leap-leap seconds sec = 59 if sec > 59 # store this before we modify it civil = year, month, day time = hour, min, sec, usec date = ::DateTime.civil(year, month, day, hour, min, sec, of) date += usec #prefill_cache date, civil, time date end # FIXME these methods are broken, I don't know why, and I don't really care right now. # we shouldn't be playing in datetime's garden anyways. if RUBY_VERSION =~ /^1\.8\./ def self.prefill_cache date, civil, time time[3] /= 86400000000.0 date.instance_variable_set :"@__#{:civil.to_i}__", [civil] date.instance_variable_set :"@__#{:time.to_i}__", [time] end else def self.prefill_cache date, civil, time time[3] /= 1000000.0 date.instance_variable_get(:@__ca__)[:civil.object_id] = civil date.instance_variable_get(:@__ca__)[:time.object_id] = time end end def self.parse_string str # special casing the common formats here gives roughly an # 8-fold speed boost over using Date._parse case str when /^(\d{4})-(\d{2})-(\d{2})(?: (\d{2}):(\d{2}):(\d{2})(\.\d+)?)?(?: ([+-]?\d{2}):?(\d{2}))?$/ parts = $~[1..-4].map { |s| s.to_i } # i feel unclean. if we have fractional seconds, pad the number and then stuff it into a rational. if $7 frac = $7.to_f * 10000000 parts << Rational(frac.to_i, 864000000000) else parts << 0 end parts << Rational(($8 || 0).to_i * 60 + ($9 || 0).to_i, 1440) else parts = ::Date._parse(str).values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction, :offset) # some defaults today = nil 8.times do |i| next if parts[i] today ||= ::Time.now.to_a.values_at(5, 4, 3) + [0, 0, 0, 0, 0] parts[i] = today[i] end parts[6] = parts[6].kind_of?(Rational) ? parts[6] : Rational(parts[6], 1) parts[6] *= Rational(1, 86400) parts[7] = Rational(parts[7], 86400) end parts end def self.parse(obj) case obj when ::DateTime return obj when ::Date return create(obj.year, obj.month, obj.day, 0, 0, 0) when ::Time return create(obj.year, obj.month, obj.day, obj.hour, obj.min, obj.sec, Rational(obj.usec, 86400000000), Rational(obj.utc_offset, 86400)) else obj = super return obj unless obj return create(*parse_string(obj.to_s)) if obj.respond_to? :to_s return create(*parse_string(obj.to_str)) if obj.respond_to? :to_str return obj end end end # # Represents a SQL BOOLEAN. Returns true/false. Falls back to Null. # class Boolean < Null def self.parse(obj) obj = super return nil if obj.nil? if obj == false or obj.kind_of? FalseClass return false elsif obj.kind_of? TrueClass return true else case obj when 't' return true when 'f' return false end if obj.respond_to? :to_i if obj.to_i == 0 return false else return true end else # punt return nil end end end end end end ruby-dbi-0.4.5/lib/dbi/typeutil.rb000066400000000000000000000100701163267757700167700ustar00rootroot00000000000000module DBI # # TypeUtil is a series of utility methods for type management. # class TypeUtil @@conversions = { } # # Register a conversion for a DBD. This applies to bound parameters for # outgoing statements; please look at DBI::Type for result sets. # # Conversions are given a driver_name, which is then used to look up # the conversion to perform on the object. Please see #convert for more # information. Driver names are typically provided by the DBD, but may # be overridden at any stage temporarily by assigning to the # +driver_name+ attribute for the various handles. # # A conversion block is normally a +case+ statement that identifies # various native ruby types and converts them to string, but ultimately # the result type is dependent on low-level driver. The resulting # object will be fed to the query as the bound value. # # The result of the block is two arguments, the first being the result # object, and the second being a +cascade+ flag, which if true # instructs #convert to run the result through the +default+ conversion # as well and use its result. This is advantageous when you just need # to convert everything to string, and allow +default+ to properly escape # it. # def self.register_conversion(driver_name, &block) raise "Must provide a block" unless block_given? @@conversions[driver_name] = block end # # Convert object for +driver_name+. See #register_conversion for a # complete explanation of how type conversion is performed. # # If the conversion is instructed to cascade, it will go to the special # "default" conversion, which is a pre-defined common case (and # mutable) ruleset for native types. Note that it will use the result # from the first conversion, not what was originally passed. Be sure to # leave the object untouched if that is your intent. E.g., if your DBD # converts an Integer to String and tells it to cascade, the "default" # conversion will get a String and quote it, not an Integer (which has # different rules). # def self.convert(driver_name, obj) if @@conversions[driver_name] newobj, cascade = @@conversions[driver_name].call(obj) if cascade return @@conversions["default"].call(newobj) end return newobj end return @@conversions["default"].call(obj) end # # Convenience method to match many SQL named types to DBI::Type classes. If # none can be matched, returns DBI::Type::Varchar. # def self.type_name_to_module(type_name) case type_name when /^int(?:\d+|eger)?$/i DBI::Type::Integer when /^varchar$/i, /^character varying$/i DBI::Type::Varchar when /^(?:float|real)$/i DBI::Type::Float when /^bool(?:ean)?$/i, /^tinyint$/i DBI::Type::Boolean when /^time(?:stamp(?:tz)?)?$/i DBI::Type::Timestamp when /^(?:decimal|numeric)$/i DBI::Type::Decimal else DBI::Type::Varchar end end end end DBI::TypeUtil.register_conversion("default") do |obj| case obj when DBI::Binary # these need to be handled specially by the driver obj when ::NilClass nil when ::TrueClass "'1'" when ::FalseClass "'0'" when ::Time, ::Date, ::DateTime "'#{::DateTime.parse(obj.to_s).strftime("%Y-%m-%dT%H:%M:%S")}'" when ::String, ::Symbol obj = obj.to_s obj = obj.gsub(/\\/) { "\\\\" } obj = obj.gsub(/'/) { "''" } "'#{obj}'" when ::BigDecimal obj.to_s("F") when ::Numeric obj.to_s else "'#{obj.to_s}'" end end ruby-dbi-0.4.5/lib/dbi/utils.rb000066400000000000000000000031401163267757700162510ustar00rootroot00000000000000# # $Id: utils.rb,v 1.5 2006/01/29 06:14:19 djberg96 Exp $ # module DBI # # Utility classes and methods for use by both DBDs and consumers. # module Utils # # Given a block, returns the execution time for the block. # def self.measure start = ::Time.now yield ::Time.now - start end # # parse a string of the form "database=xxx;key=val;..." # or database:host and return hash of key/value pairs # # Used in DBI.connect and offspring. # def self.parse_params(str) # improved by John Gorman params = str.split(";") hash = {} params.each do |param| key, val = param.split("=") hash[key] = val if key and val end if hash.empty? database, host = str.split(":") hash['database'] = database if database hash['host'] = host if host end hash end end # module Utils end # module DBI # # Type converter. # # FIXME this really needs to go into DBI::TypeUtil or similar module DBI::Utils::ConvParam # # Wrapper to convert arrays of bound objects via DBI::TypeUtil#convert. # def self.conv_param(driver_name, *params) params.collect { |param| DBI::TypeUtil.convert(driver_name, param) } end end require 'dbi/utils/date' require 'dbi/utils/time' require 'dbi/utils/timestamp' require 'dbi/utils/xmlformatter' require 'dbi/utils/tableformatter' ruby-dbi-0.4.5/lib/dbi/utils/000077500000000000000000000000001163267757700157265ustar00rootroot00000000000000ruby-dbi-0.4.5/lib/dbi/utils/date.rb000066400000000000000000000033761163267757700172010ustar00rootroot00000000000000module DBI # # Represents a Date. # # DEPRECATED: Please use a regular Date or DateTime object. # class Date attr_accessor :year, :month, :day # Aliases alias :mon :month alias :mon= :month= alias :mday :day alias :mday= :day= # Returns a new Time object based on the year, month and day or, if a # Time object was passed to the constructor, returns that object. def to_time @original_time || ::Time.local(@year, @month, @day, 0, 0, 0) end # Returns a new Date object based on the year, month and day or, if a # Date object was passed to the constructor, returns that object. def to_date @original_date || ::Date.new(@year, @month, @day) end # Returns a DBI::Date object as a string in YYYY-MM-DD format. def to_s sprintf("%04d-%02d-%02d", @year, @month, @day) end private # DBI::Date.new(year = 0, month = 0, day = 0) # DBI::Date.new(Date) # DBI::Date.new(Time) # # Creates and returns a new DBI::Date object. It's similar to the # standard Date class' constructor except that it also accepts a # Date or Time object. def initialize(year=0, month=0, day=0) case year when ::Date @year, @month, @day = year.year, year.month, year.day @original_date = year when ::Time @year, @month, @day = year.year, year.month, year.day @original_time = year else @year, @month, @day = year, month, day end end public deprecate :initialize, :public end end ruby-dbi-0.4.5/lib/dbi/utils/tableformatter.rb000066400000000000000000000103321163267757700212650ustar00rootroot00000000000000module DBI module Utils # Formats a resultset in a textual table, suitable for printing. module TableFormatter def self.coerce(obj) # :nodoc: # FIXME this is probably short-sighted. obj = "NULL" if obj.nil? obj = (obj.kind_of?(Array) or obj.kind_of?(Hash)) ? obj.inspect : obj.to_s return obj end # Perform the formatting. # # * +header+: table headers, as you'd expect they correspond to each column in the row. # * +rows+: array of array (or DBI::Row) which represent the data. # * +header_orient+: jusification of the header. :left, :right, or :center. # * +rows_orient+: justification of the rows. same as +header_orient+. # * +indent+: number of spaces to indent each line in the output. # * +cellspace+: number of spaces to pad the cell on the left and right. # * +pagebreak_after+: introduce a pagebreak each +n+ rows. # * +output+: object that responds to `<<` which will contain the output. Default is STDOUT. # # If a block is provided, +output+ will be yielded each row if # +pagebreak+ is nil, otherwise it will be yielded when the output # is complete. #-- # TODO: add a nr-column where the number of the column is shown #++ def self.ascii(header, rows, header_orient=:left, rows_orient=:left, indent=2, cellspace=1, pagebreak_after=nil, output=STDOUT) if rows.size == 0 or rows[0].size == 0 output.puts "No rows selected" return end header_orient ||= :left rows_orient ||= :left indent ||= 2 cellspace ||= 1 # pagebreak_after n-rows (without counting header or split-lines) # yield block with output as param after each pagebreak (not at the end) col_lengths = (0...(header.size)).collect do |colnr| [ (0...rows.size).collect { |rownr| value = rows[rownr][colnr] coerce(value).size }.max, header[colnr].size ].max end indent = " " * indent split_line = indent + "+" col_lengths.each {|col| split_line << "-" * (col+cellspace*2) + "+" } cellspace = " " * cellspace output_row = proc {|row, orient| output << indent + "|" row.each_with_index {|c,i| output << cellspace str = coerce(c) output << case orient when :left then str.ljust(col_lengths[i]) when :right then str.rjust(col_lengths[i]) when :center then str.center(col_lengths[i]) end output << cellspace output << "|" } output << "\n" } rownr = 0 loop do output << split_line + "\n" output_row.call(header, header_orient) output << split_line + "\n" if pagebreak_after.nil? rows.each {|ar| output_row.call(ar, rows_orient)} output << split_line + "\n" break end rows[rownr,pagebreak_after].each {|ar| output_row.call(ar, rows_orient)} output << split_line + "\n" rownr += pagebreak_after break if rownr >= rows.size yield output if block_given? end end end # module TableFormatter end end ruby-dbi-0.4.5/lib/dbi/utils/time.rb000066400000000000000000000027241163267757700172160ustar00rootroot00000000000000module DBI # # Represents a Time # # DEPRECATED: Please use a regular Time or DateTime object. class Time attr_accessor :hour, :minute, :second private # DBI::Time.new(hour = 0, minute = 0, second = 0) # DBI::Time.new(Time) # # Creates and returns a new DBI::Time object. Unlike the Time object # in the standard library, accepts an hour, minute and second, or a # Time object. def initialize(hour=0, minute=0, second=0) case hour when ::Time @hour, @minute, @second = hour.hour, hour.min, hour.sec @original_time = hour else @hour, @minute, @second = hour, minute, second end end public deprecate :initialize, :public alias :min :minute alias :min= :minute= alias :sec :second alias :sec= :second= # Returns a new Time object based on the hour, minute and second, using # the current year, month and day. If a Time object was passed to the # constructor, returns that object instead. def to_time if @original_time @original_time else t = ::Time.now ::Time.local(t.year, t.month, t.day, @hour, @minute, @second) end end # Returns a DBI::Time object as a string in HH:MM:SS format. def to_s sprintf("%02d:%02d:%02d", @hour, @minute, @second) end end end ruby-dbi-0.4.5/lib/dbi/utils/timestamp.rb000066400000000000000000000063111163267757700202570ustar00rootroot00000000000000module DBI # # Represents a Timestamp. # # DEPRECATED: Please use a regular DateTime object. # class Timestamp attr_accessor :year, :month, :day attr_accessor :hour, :minute, :second attr_writer :fraction private # DBI::Timestamp(year=0,month=0,day=0,hour=0,min=0,sec=0,fraction=nil) # DBI::Timestamp(Time) # DBI::Timestamp(Date) # # Creates and returns a new DBI::Timestamp object. This is similar to # a Time object in the standard library, but it also contains fractional # seconds, expressed in nanoseconds. In addition, the constructor # accepts either a Date or Time object. def initialize(year=0, month=0, day=0, hour=0, min=0, sec=0, fraction=nil) case year when ::Time @year, @month, @day = year.year, year.month, year.day @hour, @minute, @second, @fraction = year.hour, year.min, year.sec, nil @original_time = year when ::Date @year, @month, @day = year.year, year.month, year.day @hour, @minute, @second, @fraction = 0, 0, 0, nil @original_date = year else @year, @month, @day = year, month, day @hour, @minute, @second, @fraction = hour, min, sec, fraction end end public deprecate :initialize, :public # Returns true if +timestamp+ has a year, month, day, hour, minute, # second and fraction equal to the comparing object. # # Returns false if the comparison fails for any reason. def ==(timestamp) @year == timestamp.year and @month == timestamp.month and @day == timestamp.day and @hour == timestamp.hour and @minute == timestamp.minute and @second == timestamp.second and (fraction() == timestamp.fraction) rescue false end # Returns fractional seconds, or 0 if not set. def fraction @fraction || 0 end # Aliases alias :mon :month alias :mon= :month= alias :mday :day alias :mday= :day= alias :min :minute alias :min= :minute= alias :sec :second alias :sec= :second= # Returns a DBI::Timestamp object as a string in YYYY-MM-DD HH:MM:SS # format. If a fraction is present, then it is appended in ".FF" format. def to_s string = sprintf("%04d-%02d-%02d %02d:%02d:%02d", @year, @month, @day, @hour, @minute, @second) if @fraction fraction = ("%.9f" % (@fraction.to_i / 1e9)). to_s[1..-1].gsub(/0{1,8}$/, "") string += fraction end string end # Returns a new Time object based on the year, month and day or, if a # Time object was passed to the constructor, returns that object. def to_time @original_time || ::Time.local(@year, @month, @day, @hour, @minute, @second) end # Returns a new Date object based on the year, month and day or, if a # Date object was passed to the constructor, returns that object. def to_date @original_date || ::Date.new(@year, @month, @day) end end end ruby-dbi-0.4.5/lib/dbi/utils/xmlformatter.rb000066400000000000000000000056661163267757700210140ustar00rootroot00000000000000module DBI module Utils # Formats results in XML. module XMLFormatter # Generate XML for a row. The column names will surround the the values as tags. # # * +dbrow+: the array of the result row. # * +rowtag+: the name of the tag that encapsulates a row. # * +output+: Object that responds to `<<`. # def self.row(dbrow, rowtag="row", output=STDOUT) #XMLFormatter.extended_row(dbrow, "row", [], output << "<#{rowtag}>\n" dbrow.each_with_name do |val, name| output << " <#{name}>" + textconv(val) + "\n" end output << "\n" end # good lord, what a mess. # # nil in cols_as_tag, means "all columns expect those listed in cols_in_row_tag" # add_row_tag_attrs are additional attributes which are inserted into the row-tag def self.extended_row(dbrow, rowtag="row", cols_in_row_tag=[], cols_as_tag=nil, add_row_tag_attrs={}, output=STDOUT) if cols_as_tag.nil? cols_as_tag = dbrow.column_names - cols_in_row_tag end output << "<#{rowtag}" add_row_tag_attrs.each do |key, val| # TODO: use textconv ? " substitution? output << %{ #{key}="#{textconv(val)}"} end cols_in_row_tag.each do |key| # TODO: use textconv ? " substitution? output << %{ #{key}="#{dbrow[key]}"} end output << ">\n" cols_as_tag.each do |key| output << " <#{key}>" + textconv(dbrow[key]) + "\n" end output << "\n" end # generate a full XML representation of the table. # # Arguments and output are similar to #row, with the exception of # +roottag+, which is a container for the individual row tags. # def self.table(rows, roottag = "rows", rowtag = "row", output=STDOUT) output << '' output << "\n<#{roottag}>\n" rows.each do |row| row(row, rowtag, output) end output << "\n" end class << self private # Your standard XML entity conversions. def textconv(str) str = str.to_s.gsub('&', "&") str = str.gsub('\'', "'") str = str.gsub('"', """) str = str.gsub('<', "<") str.gsub('>', ">") end end # class self end # module XMLFormatter end end ruby-dbi-0.4.5/metadata.yml000066400000000000000000000050621163267757700155700ustar00rootroot00000000000000--- !ruby/object:Gem::Specification name: dbi version: !ruby/object:Gem::Version prerelease: false segments: - 0 - 4 - 5 version: 0.4.5 platform: ruby authors: - Erik Hollensbe - Christopher Maujean autorequire: bindir: bin cert_chain: [] date: 2010-05-17 00:00:00 -04:00 default_executable: dependencies: - !ruby/object:Gem::Dependency name: deprecated prerelease: false requirement: &id001 !ruby/object:Gem::Requirement requirements: - - "=" - !ruby/object:Gem::Version segments: - 2 - 0 - 1 version: 2.0.1 type: :runtime version_requirements: *id001 description: A vendor independent interface for accessing databases, similar to Perl's DBI email: ruby-dbi-users@rubyforge.org executables: - dbi - test_broken_dbi extensions: [] extra_rdoc_files: - README - LICENSE - ChangeLog files: - examples/test1.pl - examples/test1.rb - examples/xmltest.rb - bin/dbi - build/Rakefile.dbi.rb - lib/dbi.rb - lib/dbi/base_classes/database.rb - lib/dbi/base_classes/driver.rb - lib/dbi/base_classes/statement.rb - lib/dbi/base_classes.rb - lib/dbi/binary.rb - lib/dbi/columninfo.rb - lib/dbi/exceptions.rb - lib/dbi/handles/database.rb - lib/dbi/handles/driver.rb - lib/dbi/handles/statement.rb - lib/dbi/handles.rb - lib/dbi/row.rb - lib/dbi/sql/preparedstatement.rb - lib/dbi/sql.rb - lib/dbi/sql_type_constants.rb - lib/dbi/trace.rb - lib/dbi/types.rb - lib/dbi/typeutil.rb - lib/dbi/utils/date.rb - lib/dbi/utils/tableformatter.rb - lib/dbi/utils/time.rb - lib/dbi/utils/timestamp.rb - lib/dbi/utils/xmlformatter.rb - lib/dbi/utils.rb - test/ts_dbi.rb - test/dbi/tc_columninfo.rb - test/dbi/tc_date.rb - test/dbi/tc_dbi.rb - test/dbi/tc_row.rb - test/dbi/tc_sqlbind.rb - test/dbi/tc_statementhandle.rb - test/dbi/tc_time.rb - test/dbi/tc_timestamp.rb - test/dbi/tc_types.rb - README - LICENSE - ChangeLog has_rdoc: true homepage: http://www.rubyforge.org/projects/ruby-dbi licenses: [] post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version segments: - 1 - 8 - 0 version: 1.8.0 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version segments: - 0 version: "0" requirements: [] rubyforge_project: ruby-dbi rubygems_version: 1.3.6 signing_key: specification_version: 3 summary: A vendor independent interface for accessing databases, similar to Perl's DBI test_files: - test/ts_dbi.rb ruby-dbi-0.4.5/test/000077500000000000000000000000001163267757700142415ustar00rootroot00000000000000ruby-dbi-0.4.5/test/dbi/000077500000000000000000000000001163267757700147775ustar00rootroot00000000000000ruby-dbi-0.4.5/test/dbi/tc_columninfo.rb000066400000000000000000000050771163267757700201740ustar00rootroot00000000000000############################################################ # tc_columninfo.rb # # Test case for the DBI::ColumnInfo class. ############################################################ $LOAD_PATH.unshift(Dir.pwd) $LOAD_PATH.unshift(File.dirname(Dir.pwd)) $LOAD_PATH.unshift("../../lib") $LOAD_PATH.unshift("../../lib/dbi") $LOAD_PATH.unshift("lib") require "dbi/columninfo" require "test/unit" class TC_DBI_ColumnInfo < Test::Unit::TestCase def setup @colinfo = DBI::ColumnInfo.new( "name" => "test", "sql_type" => "numeric", "type_name" => "test_type_name", "precision" => 2, "scale" => 2, "default" => 100.00, "nullable" => false, "indexed" => true, "primary" => true, "unique" => false ) @keys = %w/name sql_type type_name precision scale default nullable indexed primary unique / end def test_constructor assert_nothing_raised{ DBI::ColumnInfo.new } assert_nothing_raised do DBI::ColumnInfo.new({"foo" => "bar", "baz" => "quux"}) DBI::ColumnInfo.new({:foo => "bar", :baz => "quux"}) end assert_raises(TypeError) do DBI::ColumnInfo.new({"foo" => "bar", :foo => "quux"}) end end def test_accessors assert_nothing_raised do @keys.each do |x| assert_equal(@colinfo[x], @colinfo[x.to_sym]) assert_equal(@colinfo.send(x.to_sym), @colinfo[x.to_sym]) @colinfo[x] = "poop" assert_equal("poop", @colinfo[x]) assert_equal("poop", @colinfo[x.to_sym]) end end end def test_precision_basic assert_respond_to(@colinfo, :size) assert_respond_to(@colinfo, :size=) assert_respond_to(@colinfo, :length) assert_respond_to(@colinfo, :length=) end def test_scale_basic assert_respond_to(@colinfo, :decimal_digits) assert_respond_to(@colinfo, :decimal_digits=) end def test_default_value_basic assert_respond_to(@colinfo, :default_value) assert_respond_to(@colinfo, :default_value=) end def test_unique_basic assert_respond_to(@colinfo, :is_unique) end def test_keys assert_respond_to(@colinfo, :keys) assert_equal(@keys.sort, @colinfo.keys.collect { |x| x.to_s }.sort) end def test_respond_to_hash_methods assert_respond_to(@colinfo, :each) assert_respond_to(@colinfo, :empty?) assert_respond_to(@colinfo, :has_key?) end def teardown @colinfo = nil end end ruby-dbi-0.4.5/test/dbi/tc_date.rb000066400000000000000000000046051163267757700167340ustar00rootroot00000000000000############################################################################## # tc_date.rb # # Test case for the DBI::Date class (currently) located in the utils.rb file. ############################################################################## $LOAD_PATH.unshift(Dir.pwd) $LOAD_PATH.unshift(File.dirname(Dir.pwd)) $LOAD_PATH.unshift("../../lib") $LOAD_PATH.unshift("../../lib/dbi") $LOAD_PATH.unshift("lib") require 'date' require 'dbi' require 'test/unit' Deprecate.set_action(proc { }) class TC_DBI_Date < Test::Unit::TestCase def setup @date = Date.new @time = Time.now @dbi_date = DBI::Date.new end def test_constructor assert_nothing_raised{ DBI::Date.new(2006) } assert_nothing_raised{ DBI::Date.new(2006, 1) } assert_nothing_raised{ DBI::Date.new(2006, 1, 20) } assert_nothing_raised{ DBI::Date.new(Date.new) } assert_nothing_raised{ DBI::Date.new(Time.now) } end def test_year assert_respond_to(@dbi_date, :year) assert_respond_to(@dbi_date, :year=) assert_equal(0, @dbi_date.year) end def test_month assert_respond_to(@dbi_date, :month) assert_respond_to(@dbi_date, :month=) end # An alias for :month, :month= def test_mon assert_respond_to(@dbi_date, :mon) assert_respond_to(@dbi_date, :mon=) assert_equal(0, @dbi_date.mon) end def test_day assert_respond_to(@dbi_date, :day) assert_respond_to(@dbi_date, :day=) assert_equal(0, @dbi_date.day) end # An alias for :day, :day= def test_mday assert_respond_to(@dbi_date, :mday) assert_respond_to(@dbi_date, :mday=) end def test_to_time assert_respond_to(@dbi_date, :to_time) assert_equal(@time, DBI::Date.new(@time).to_time) assert_equal(@time.object_id, DBI::Date.new(@time).to_time.object_id) end def test_to_date assert_respond_to(@dbi_date, :to_date) assert_equal(@date, DBI::Date.new(@date).to_date) assert_equal(@date.object_id, DBI::Date.new(@date).to_date.object_id) end # We test .to_s because it has an explicit implementation def test_to_s assert_respond_to(@dbi_date, :to_s) assert_nothing_raised{ @dbi_date.to_s } assert_kind_of(String, @dbi_date.to_s) assert_equal("0000-00-00", @dbi_date.to_s) end def teardown @date = nil @time = nil @dbi_date = nil end end ruby-dbi-0.4.5/test/dbi/tc_dbi.rb000066400000000000000000000145201163267757700165520ustar00rootroot00000000000000###################################################################### # tc_dbi.rb # # Test case for the DBI module (dbi.rb). ###################################################################### $LOAD_PATH.unshift(Dir.pwd) $LOAD_PATH.unshift(File.dirname(Dir.pwd)) $LOAD_PATH.unshift("../../lib") $LOAD_PATH.unshift("../../lib/dbi") $LOAD_PATH.unshift("lib") require 'dbi' require 'test/unit' class TC_DBI < Test::Unit::TestCase def setup @db_error = DBI::DatabaseError.new("test", 1, "montana") @db_binary = DBI::Binary.new("test") @url_basic = 'dbi:foo:bar' @url_inter = 'dbi:foo:bar:host' @url_advan = 'dbi:foo:database=db;host=xx;port=99' end def test_dbi_version assert_equal("0.4.5", DBI::VERSION) end def test_dbd_module assert_equal("0.3", DBI::DBD::API_VERSION) end def test_fetch_scroll_constants assert_equal(1, DBI::SQL_FETCH_NEXT) assert_equal(2, DBI::SQL_FETCH_PRIOR) assert_equal(3, DBI::SQL_FETCH_FIRST) assert_equal(4, DBI::SQL_FETCH_LAST) assert_equal(5, DBI::SQL_FETCH_ABSOLUTE) assert_equal(6, DBI::SQL_FETCH_RELATIVE) end def test_sql_type_constants assert_equal(1, DBI::SQL_CHAR) assert_equal(2, DBI::SQL_NUMERIC) assert_equal(3, DBI::SQL_DECIMAL) assert_equal(4, DBI::SQL_INTEGER) assert_equal(5, DBI::SQL_SMALLINT) assert_equal(6, DBI::SQL_FLOAT) assert_equal(7, DBI::SQL_REAL) assert_equal(8, DBI::SQL_DOUBLE) assert_equal(9, DBI::SQL_DATE) assert_equal(10, DBI::SQL_TIME) assert_equal(11, DBI::SQL_TIMESTAMP) assert_equal(12, DBI::SQL_VARCHAR) assert_equal(100, DBI::SQL_OTHER) assert_equal(-1, DBI::SQL_LONGVARCHAR) assert_equal(-2, DBI::SQL_BINARY) assert_equal(-3, DBI::SQL_VARBINARY) assert_equal(-4, DBI::SQL_LONGVARBINARY) assert_equal(-5, DBI::SQL_BIGINT) assert_equal(-6, DBI::SQL_TINYINT) assert_equal(-7, DBI::SQL_BIT) assert_equal(-10, DBI::SQL_BLOB) assert_equal(-11, DBI::SQL_CLOB) end def test_sql_type_names assert_equal('BIT', DBI::SQL_TYPE_NAMES[DBI::SQL_BIT]) assert_equal('TINYINT', DBI::SQL_TYPE_NAMES[DBI::SQL_TINYINT]) assert_equal('SMALLINT', DBI::SQL_TYPE_NAMES[DBI::SQL_SMALLINT]) assert_equal('INTEGER', DBI::SQL_TYPE_NAMES[DBI::SQL_INTEGER]) assert_equal('BIGINT', DBI::SQL_TYPE_NAMES[DBI::SQL_BIGINT]) assert_equal('FLOAT', DBI::SQL_TYPE_NAMES[DBI::SQL_FLOAT]) assert_equal('REAL', DBI::SQL_TYPE_NAMES[DBI::SQL_REAL]) assert_equal('DOUBLE', DBI::SQL_TYPE_NAMES[DBI::SQL_DOUBLE]) assert_equal('NUMERIC', DBI::SQL_TYPE_NAMES[DBI::SQL_NUMERIC]) assert_equal('DECIMAL', DBI::SQL_TYPE_NAMES[DBI::SQL_DECIMAL]) assert_equal('CHAR', DBI::SQL_TYPE_NAMES[DBI::SQL_CHAR]) assert_equal('VARCHAR', DBI::SQL_TYPE_NAMES[DBI::SQL_VARCHAR]) assert_equal('LONG VARCHAR', DBI::SQL_TYPE_NAMES[DBI::SQL_LONGVARCHAR]) assert_equal('DATE', DBI::SQL_TYPE_NAMES[DBI::SQL_DATE]) assert_equal('TIME', DBI::SQL_TYPE_NAMES[DBI::SQL_TIME]) assert_equal('TIMESTAMP', DBI::SQL_TYPE_NAMES[DBI::SQL_TIMESTAMP]) assert_equal('BINARY', DBI::SQL_TYPE_NAMES[DBI::SQL_BINARY]) assert_equal('VARBINARY', DBI::SQL_TYPE_NAMES[DBI::SQL_VARBINARY]) assert_equal('LONG VARBINARY', DBI::SQL_TYPE_NAMES[DBI::SQL_LONGVARBINARY]) assert_equal('BLOB', DBI::SQL_TYPE_NAMES[DBI::SQL_BLOB]) assert_equal('CLOB', DBI::SQL_TYPE_NAMES[DBI::SQL_CLOB]) assert_equal(nil, DBI::SQL_TYPE_NAMES[DBI::SQL_OTHER]) end def test_dbi_exception_classes assert(DBI::Error) assert(DBI::Warning) assert(DBI::InterfaceError) assert(DBI::NotImplementedError) assert(DBI::DatabaseError) assert(DBI::DataError) assert(DBI::OperationalError) assert(DBI::IntegrityError) assert(DBI::InternalError) assert(DBI::ProgrammingError) assert(DBI::NotSupportedError) end # This error class gets extra testing since it defines some custom # accessors. def test_dbi_database_error assert_respond_to(@db_error, :errstr) assert_respond_to(@db_error, :err) assert_respond_to(@db_error, :state) assert_equal("test", @db_error.errstr) assert_equal(1, @db_error.err) assert_equal("montana", @db_error.state) end def test_binary_datatype assert_respond_to(@db_binary, :data) assert_respond_to(@db_binary, :to_s) assert_equal("test", @db_binary.data) assert_equal("test", @db_binary.to_s) end def test_misc_constants assert_equal(2, DBI::DEFAULT_TRACE_MODE) assert_equal(STDERR, DBI::DEFAULT_TRACE_OUTPUT) end def test_last_connection assert_respond_to(DBI, :last_connection) end def test_convert_types assert_respond_to(DBI, :convert_types) assert_respond_to(DBI, :convert_types=) end def test_connect assert_respond_to(DBI, :connect) end def test_available_drivers assert_respond_to(DBI, :available_drivers) assert_equal( [ "dbi:Mysql:", "dbi:ODBC:", "dbi:Pg:", "dbi:SQLite3:", "dbi:SQLite:" ], DBI.available_drivers.sort) end # PRIVATE METHODS def test_parse_url assert_nothing_raised{ DBI.send(:parse_url, "dbi:foo:bar") } assert_equal(["foo","bar"], DBI.send(:parse_url, @url_basic)) assert_equal(["foo","bar:host"], DBI.send(:parse_url, @url_inter)) assert_equal(["foo","database=db;host=xx;port=99"], DBI.send(:parse_url, @url_advan) ) end def test_parse_url_expected_errors assert_raises(DBI::InterfaceError){ DBI.send(:parse_url, 'dbi') } assert_raises(DBI::InterfaceError){ DBI.send(:parse_url, 'dbi::foo') } # XXX we're looking for a specific exception message here assert_nothing_raised do begin DBI.send(:parse_url, 'dbi:blah') rescue DBI::InterfaceError => e assert true assert_kind_of DBI::InterfaceError, e assert_equal "Invalid Data Source Name", e.message end end end def teardown @db_error = nil @db_binary = nil end end ruby-dbi-0.4.5/test/dbi/tc_row.rb000066400000000000000000000200501163267757700166160ustar00rootroot00000000000000###################################################################### # tc_row.rb # # Test case for the DBI::Row class. ###################################################################### $LOAD_PATH.unshift(Dir.pwd) $LOAD_PATH.unshift(File.dirname(Dir.pwd)) $LOAD_PATH.unshift("../../lib") $LOAD_PATH.unshift("../../lib/dbi") $LOAD_PATH.unshift("lib") require 'test/unit' require 'dbi' class TC_DBI_Row < Test::Unit::TestCase def setup @data = %w/Daniel Berger 36/ @cols = %w/first last age/ @coltypes = [DBI::Type::Varchar, DBI::Type::Varchar, DBI::Type::Integer] @row = DBI::Row.new(@cols, @coltypes, @data.clone) @row_noconv = DBI::Row.new(@cols, @coltypes, @data.clone, false) end def teardown @data = nil @cols = nil @row = nil end def test_row_multiassign # this should only be an issue in 1.8.7 and up, if at all. first, last, age = @row assert_equal("Daniel", first) assert_equal("Berger", last) assert_equal(36, age) end def test_row_noconv assert_nothing_raised do assert_equal( [ 'Daniel', 'Berger', 36 ], @row ) assert_equal(@data, @row_noconv) end end # Ensure that constructor only allows Integers or Arrays (or nil) def test_row_constructor assert_nothing_raised{ DBI::Row.new(@cols, @coltypes) } assert_nothing_raised{ DBI::Row.new(@cols, @coltypes, 1) } assert_nothing_raised{ DBI::Row.new(@cols, @coltypes, nil) } assert_nothing_raised{ DBI::Row.new(@cols, @coltypes, [1,2,3])} assert_raises(ArgumentError){ DBI::Row.new } assert_raises(ArgumentError){ DBI::Row.new(@cols) } assert_raises(TypeError){ DBI::Row.new(@cols, @coltypes, {}) } end # Test added to ensure that Row#at is equivalent to Row#by_index. When the # latter method is (hopefully) removed, this test can be removed as well. def test_at assert_respond_to(@row, :at) assert_equal(@data[0].to_s, @row.at(0).to_s) assert_equal(@data[1].to_s, @row.at(1).to_s) assert_equal(@data[2].to_s, @row.at(2).to_s) assert_equal(@data[99].to_s, @row.at(99).to_s) end # Should respond to Array and Enumerable methods def test_row_delegate assert_respond_to(@row, :length) assert_respond_to(@row, :each) assert_respond_to(@row, :grep) end def test_row_length assert_equal(3, @row.length) assert_equal(3, DBI::Row.new(@cols, @coltypes).length) end def test_row_data_by_index assert_equal(@data[0], @row.by_index(0)) assert_equal(@data[1], @row.by_index(1)) assert_equal(@data[2], @row.by_index(2).to_s) assert_nil(@row.by_index(3)) end def test_row_data_by_field assert_equal @data[0], @row.by_field('first') assert_equal @data[1], @row.by_field('last') assert_equal @data[2], @row.by_field('age').to_s assert_equal nil, @row.by_field('unknown') end def test_row_set_values assert_respond_to(@row, :set_values) assert_nothing_raised{ @row.set_values(["John", "Doe", 23]) } assert_equal("John", @row.by_index(0)) assert_equal("Doe", @row.by_index(1)) assert_equal(23, @row.by_index(2)) end def test_row_to_h assert_respond_to(@row, :to_h) assert_nothing_raised{ @row.to_h } assert_kind_of(Hash, @row.to_h) assert_equal({"first"=>"Daniel", "last"=>"Berger", "age"=>36}, @row.to_h) end def test_row_column_names assert_respond_to(@row, :column_names) assert_nothing_raised{ @row.column_names } assert_kind_of(Array, @row.column_names) assert_equal(["first", "last", "age"], @row.column_names) end # An alias for column_names def test_row_field_names assert_respond_to(@row, :column_names) assert_nothing_raised{ @row.column_names } assert_kind_of(Array, @row.column_names) assert_equal(["first", "last", "age"], @row.column_names) end def test_indexing_numeric assert_equal(@data[0], @row[0]) assert_equal(@data[1], @row[1]) assert_equal(@data[2], @row[2].to_s) end def test_indexing_string_or_symbol assert_equal(@data[0], @row['first']) assert_equal(@data[0], @row[:first]) assert_equal(@data[1], @row['last']) assert_equal(@data[2], @row['age'].to_s) assert_equal(nil, @row['unknown']) end def test_indexing_regexp assert_equal(["Daniel"], @row[/first/]) assert_equal(["Berger"], @row[/last/]) assert_equal([36], @row[/age/]) assert_equal(["Daniel", "Berger"], @row[/first|last/]) assert_equal([], @row[/bogus/]) end def test_indexing_array assert_equal(["Daniel"], @row[[0]]) assert_equal(["Daniel"], @row[["first"]]) assert_equal(["Berger"], @row[[1]]) assert_equal([36], @row[[2]]) assert_equal([nil], @row[[3]]) assert_equal(["Daniel", 36], @row[[0,2]]) assert_equal(["Daniel", 36], @row[[0,:age]]) end def test_indexing_range assert_equal(["Daniel","Berger"], @row[0..1]) assert_equal(["Berger",36], @row[1..2]) assert_equal(["Berger",36], @row[1..99]) assert_equal(nil, @row[90..100]) end # The two argument reference should behave like the second form of Array#[] def test_indexing_two_args assert_equal([], @row[0,0]) assert_equal(["Daniel"], @row[0,1]) assert_equal(["Daniel", "Berger"], @row[0,2]) assert_equal(["Daniel", "Berger", 36], @row[0,3]) assert_equal(["Daniel", "Berger", 36], @row[0,99]) end def test_indexing_multiple_args assert_equal(["Berger", 36, "Daniel"], @row[:last, :age, :first]) assert_equal(["Berger", 36, "Daniel"], @row[1, :age, :first]) assert_equal(["Berger", 36, "Daniel"], @row[1, 2, :first]) assert_equal(["Berger", 36, "Daniel"], @row[1, 2, 0]) assert_equal(["Berger", 36, "Daniel", nil], @row[1, 2, 0, 9]) assert_equal(["Berger", 36, "Daniel", nil], @row[1, 2, 0, :bogus]) end def test_indexing_assignment assert_nothing_raised{ @row[0] = "kirk" } assert_equal("kirk", @row[0]) assert_nothing_raised{ @row[:age] = 29 } assert_equal(29, @row[:age]) assert_nothing_raised{ @row[1,2] = "francis" } assert_equal("francis", @row[:last]) assert_nil(@row[:age]) end def test_clone_with another_row = @row.clone_with(["Jane", "Smith", 33]) assert_kind_of(DBI::Row, another_row) assert_equal "Jane", another_row.by_index(0) assert_equal "Smith", another_row.by_index(1) assert_equal 33, another_row.by_index(2) assert(@row != another_row) end def test_iteration expect = @data.clone @row.each { |value| assert_equal(expect.shift, value.to_s) } assert_equal([], expect) @row.collect { |value| "Field=#{value}" } end def test_row_each_with_name assert_respond_to(@row, :each_with_name) assert_nothing_raised{ @row.each_with_name{ } } @row.each_with_name{ |value, column| assert(@cols.include?(column)) assert(@data.include?(value.to_s)) } end def test_to_a assert_respond_to(@row, :to_a) assert_equal(@data, DBI::Row.new(@cols, @coltypes, @data).to_a.collect { |x| x.to_s }) end def test_dup_clone dupped = nil cloned = nil assert_nothing_raised{ dupped = @row.dup } assert_nothing_raised{ cloned = @row.clone } assert_nothing_raised{ @row.set_values(["Bill", "Jones", 16])} assert_equal(@data, dupped.to_a.collect { |x| x.to_s }) assert_equal(@data, cloned.to_a.collect { |x| x.to_s }) assert(dupped.object_id != @row.object_id) assert(cloned.object_id != @row.object_id) end def test_dup_ruby18 res = [] r = DBI::Row.new(["col1","col2"],[nil,nil]) [["one",1],["two",2],["three",3]].each do |x,y| r["col1"] = x r["col2"] = y res << r.dup end assert_equal res, [["one", 1], ["two", 2], ["three", 3]] end end ruby-dbi-0.4.5/test/dbi/tc_sqlbind.rb000066400000000000000000000104321163267757700174460ustar00rootroot00000000000000$: << 'lib' require 'test/unit' require "dbi/sql" # ==================================================================== class TestSqlBind < Test::Unit::TestCase def bind(quoter, sql, args) ps = DBI::SQL::PreparedStatement.new(quoter, sql) ps.bind(DBI::Utils::ConvParam.conv_param('default', *args)) end def test_one assert_equal "10", bind(self, "?", [10]) assert_equal "'hi'", bind(self, "?", ["hi"]) assert_equal "I 'don''t' know", bind(self, "I ? know", ["don't"]) end def test_many assert_equal "WHERE age=12 AND name='Jim'", bind(self, "WHERE age=? AND name=?", [12, 'Jim']) end def test_too_many assert_raises (RuntimeError) { bind(self, "age=?", [10, 11]) } end def test_too_few assert_raises (RuntimeError) { bind(self, "age in (?, ?, ?)", [10, 11]) } end def test_embedded_questions assert_equal "10 ? 11", bind(self, "? ?? ?", [10, 11]) assert_equal "????", bind(self, "????????", []) end def test_questions_in_param assert_equal "WHERE c='connected?'", bind(self, "WHERE c=?", ["connected?"]) assert_equal "WHERE c='connected?' AND d='???'", bind(self, "WHERE c=? AND d=?", ["connected?", "???"]) end def test_questions_in_quotes assert_equal "WHERE c='connected?' AND d=10", bind(self, "WHERE c='connected?' AND d=?", [10]) end def test_comment_dan sql = %{--Dan's query\n--random comment\nselect column1, column2\nfrom table1\nwhere somevalue = ?} res = %{--Dan's query\n--random comment\nselect column1, column2\nfrom table1\nwhere somevalue = 10} assert_equal res, bind(self, sql, [10]) end def test_minus_bug sql = "SELECT 1 - 3" res = "SELECT 1 - 3" assert_equal res, bind(self, sql, []) end def test_minus2 sql = "SELECT * from test --Dan's query" assert_equal sql, bind(self, sql, []) end def test_slash sql = "SELECT 5 / 4" res = "SELECT 5 / 4" assert_equal res, bind(self, sql, []) end def test_much sql = <