# # spec file for package perl-SQL-Abstract # # Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: perl-SQL-Abstract Version: 1.85 Release: 26.2 %define cpan_name SQL-Abstract Summary: Generate SQL from Perl data structures License: Artistic-1.0 or GPL-1.0+ Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/SQL-Abstract/ Source0: https://cpan.metacpan.org/authors/id/I/IL/ILMARI/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(Hash::Merge) >= 0.12 BuildRequires: perl(MRO::Compat) >= 0.12 BuildRequires: perl(Moo) >= 2.000001 BuildRequires: perl(Sub::Quote) >= 2.000001 BuildRequires: perl(Test::Deep) >= 0.101 BuildRequires: perl(Test::Exception) >= 0.310000 BuildRequires: perl(Test::More) >= 0.88 BuildRequires: perl(Test::Warn) BuildRequires: perl(Text::Balanced) >= 2.00 Requires: perl(Hash::Merge) >= 0.12 Requires: perl(MRO::Compat) >= 0.12 Requires: perl(Moo) >= 2.000001 Requires: perl(Sub::Quote) >= 2.000001 Requires: perl(Text::Balanced) >= 2.00 %{perl_requires} %description This module was inspired by the excellent DBIx::Abstract. However, in using that module I found that what I really wanted to do was generate SQL, but still retain complete control over my statement handles and use the DBI interface. So, I set out to create an abstract SQL generation module. While based on the concepts used by DBIx::Abstract, there are several important differences, especially when it comes to WHERE clauses. I have modified the concepts used to make the SQL easier to generate from Perl data structures and, IMO, more intuitive. The underlying idea is for this module to do what you mean, based on the data structures you provide it. The big advantage is that you don't have to modify your code every time your data changes, as this module figures it out. To begin with, an SQL INSERT is as easy as just specifying a hash of 'key=value' pairs: my %data = ( name => 'Jimbo Bobson', phone => '123-456-7890', address => '42 Sister Lane', city => 'St. Louis', state => 'Louisiana', ); The SQL can then be generated with this: my($stmt, @bind) = $sql->insert('people', \%data); Which would give you something like this: $stmt = "INSERT INTO people (address, city, name, phone, state) VALUES (?, ?, ?, ?, ?)"; @bind = ('42 Sister Lane', 'St. Louis', 'Jimbo Bobson', '123-456-7890', 'Louisiana'); These are then used directly in your DBI code: my $sth = $dbh->prepare($stmt); $sth->execute(@bind); %prep %setup -q -n %{cpan_name}-%{version} find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644 %build %{__perl} Makefile.PL INSTALLDIRS=vendor %{__make} %{?_smp_mflags} %check %{__make} test %install %perl_make_install %perl_process_packlist %perl_gen_filelist %files -f %{name}.files %defattr(-,root,root,755) %doc Changes examples README %changelog * Wed Jan 31 2018 coolo@suse.com - updated to 1.85 see /usr/share/doc/packages/perl-SQL-Abstract/Changes 1.85 - 2018-01-27 - Restore perl version requirement missed in the Distar port - Factor out the SET ... part of UPDATE for subclassability (GH#12) * Tue Apr 4 2017 coolo@suse.com - updated to 1.84 see /usr/share/doc/packages/perl-SQL-Abstract/Changes 1.84 - 2017-04-03 - Restore 'dynamic_config => 0' missed in the Distar port 1.83 - 2017-04-03 - Support for DELETE ... RETURNING (GH#9) - Port to Distar * Tue Mar 21 2017 coolo@suse.com - updated to 1.82 see /usr/share/doc/packages/perl-SQL-Abstract/Changes revision 1.82 2017-03-20 - ------------------------ - Add explicit dependency on Sub::Quote (GH#8) - Fix syntax errors in ORDER BY docs (GH#7) revision 1.81_01 2017-02-28 - --------------------------- - Fix order clauses with bind parameters in ->where - Fix ->insert($table, \@values) with >26 values (RT#112684) - Teach ::Tree that ILIKE (PostgreSQL) and REGEXP (MySQL) are binary ops - Support for UPDATE ... RETURNING - Documentation improvements for ORDER BY * Wed Nov 12 2014 coolo@suse.com - updated to 1.81 - Fix overly-enthusiastic parenthesis unroller (RT#99503) revision 1.80 2014-10-05 - --------------------------- - Fix erroneous behavior of is_literal_value($) wrt { -ident => ... } - Explicitly croak on top-level special ops (they didn't work anyway) revision 1.79 2014-09-25 - --------------------------- - New exportable functions: is_literal_value($) and is_plain_value($) - New attribute 'escape_char' allowing for proper escape of quote_chars present in an identifier - Deprecate { "" => \... } constructs - Treat { -value => undef } as plain undef in all cases - Explicitly throw on { -ident => undef } * Mon Sep 15 2014 coolo@suse.com - updated to 1.78 - Fix parsing of binary ops to correctly take up only a single LHS element, instead of gobbling up the entire parse-to-date - Explicitly handle ROW_NUMBER() OVER as the snowflake-operator it is - Improve signatures/documentation of is_same_sql_bind / eq_sql_bind - Retire script/format-sql - the utility needs more work to be truly end-user convenient * Mon Feb 24 2014 coolo@suse.com - updated to 1.77 - Reintroduce { -not => undef } column operator (regression from 1.75) - *UPCOMING INCOMPATIBLE BUGFIX*: SQLA used to generate incorrect SQL on undef-containing lists fed to -in and -not_in. An exception will be raised for a while before properly fixing this, to avoid quiet but subtle changes to query results in production - Deprecate and warn when supplying an empty arrayref to like/not_like operators (likely to be removed before 2.0) - Warn when using an inequality operator with a multi-value array to arrive at what amounts to a 1=1 condition (no pre-2.0 plans to fix this behavior due to backwards comp concerns) - Fix false negative comparison of ORDER BY ASC - More improvements of incorrect parsing (placeholder at end of list element) - Fix typos in POD and comments (RT#87776) - Augment -not_bool example with nesting (RT#89601) * Sat Jul 27 2013 coolo@suse.com - updated to 1.74 - Fix insufficient parenthesis unroll during operator comparison - 'ORDER BY foo' and 'ORDER BY foo ASC' are now considered equal by default (with a switch to reenable old behavior when necessary) - Change parser to not eagerly slurp RHS expressions it doesn't recognize * Tue Jun 4 2013 coolo@suse.com - updated to 1.73 - Fix parsing of ORDER BY foo + ? - Stop filling in placeholders in `format-sql` since it does not support passing values for them anyway - Fix parsing of NOT EXISTS - Fix over-eager parenthesis unrolling - Fix deep recursion warnings while parsing obnoxiously long sql statements - Fix incorrect comparison of malformed lists - Fix incorrect reporting of mismatch-members in SQLA::Test - Migrate the -ident operator from DBIC into SQLA - Migrate the -value operator from DBIC into SQLA * Thu Mar 31 2011 coolo@novell.com - update to 1.72 * lots of changes, see Changes * Wed Dec 1 2010 coolo@novell.com - switch to perl_requires macro * Fri Dec 11 2009 chris@computersalat.de - update to version 1.60 * lot of changes, see Changes - cleanup spec * added header * sorted Tags * fixed build-/deps * added author * moved changelog to .changes - added perl-macros * perl_gen_filelist * Sun Oct 26 2008 gerrit.beine@gmx.de - first release 1.24