File: 99backtick.t

package info (click to toggle)
libsql-statement-perl 1.414-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 804 kB
  • sloc: perl: 10,528; makefile: 14
file content (74 lines) | stat: -rw-r--r-- 1,862 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/perl -w
use strict;
use warnings;
no warnings 'uninitialized';
use lib qw(t);

use Test::More;
use Params::Util qw(_INSTANCE);
use TestLib qw(connect prove_reqs show_reqs);

my ( $required, $recommended ) = prove_reqs();
my @test_dbds = ( 'SQL::Statement', grep { /^dbd:/i } keys %{$recommended} );

foreach my $test_dbd (@test_dbds)
{
    my $dbh;

    # Test RaiseError for prepare errors
    #
    my %extra_args;
    if ( $test_dbd =~ m/^DBD::/i )
    {
	$extra_args{sql_dialect} = "ANSI";
    }
    $dbh = connect(
                    $test_dbd,
                    {
                       PrintError => 0,
                       RaiseError => 0,
		       %extra_args,
                    }
                  );

    for my $sql(
		split /\n/, <<""
  /* DROP TABLE */
DROP TABLE `foo`
  /* DELETE */
DELETE FROM `foo`
  /* UPDATE */
UPDATE `foo` SET bar = 7
  /* INSERT */
INSERT INTO `foo` (col1,col2,col7) VALUES ( 'baz', 7, NULL )
  /* CREATE TABLE */
CREATE TABLE `foo` ( id INT )
CREATE LOCAL TEMPORARY TABLE `foo` (id INT)
CREATE GLOBAL TEMPORARY TABLE `foo` (id INT)
CREATE TABLE `foo` ( phrase NUMERIC(4,6) )
  /* SELECT COLUMNS */
SELECT id, phrase FROM `foo`
SELECT * FROM `foo`
  /* SET FUNCTIONS */
SELECT MAX(`foo`) FROM bar
  /* ORDER BY */
SELECT * FROM `foo` ORDER BY bar
SELECT * FROM `foo` ORDER BY bar, baz
  /* LIMIT */
SELECT * FROM `foo` LIMIT 5
  /* TABLE NAME ALIASES */
SELECT * FROM `test` as `T1`
  /* PARENS */
SELECT * FROM `ztable` WHERE NOT `data` IN ('one','two')
  /* NOT */
SELECT * FROM `foo` WHERE NOT bar = 'baz' AND bop = 7 OR NOT blat = bar
  /* IN */
SELECT * FROM bar WHERE `foo` IN ('aa','ab','ba','bb')
  /* BETWEEN */
SELECT * FROM bar WHERE `foo` BETWEEN ('aa','bb')

	       ) {
	ok( eval { $dbh->prepare($sql); }, "parse '$sql' using $test_dbd" ) or diag( $dbh->errstr() );
    }
}
done_testing();