package SQL::Translator::Parser::SqlfXML;
# -------------------------------------------------------------------
-# $Id: SqlfXML.pm,v 1.2 2003-08-06 22:08:16 grommit Exp $
+# $Id: SqlfXML.pm,v 1.3 2003-08-07 14:49:24 grommit Exp $
# -------------------------------------------------------------------
# Copyright (C) 2003 Mark Addison <mark.addison@itn.co.uk>,
#
<sqlf:default_value>EMPTY_STRING</sqlf:default_value> <!-- Empty string -->
<sqlf:default_value>NULL</sqlf:default_value> <!-- NULL -->
+ <sqlf:default_value/> <!-- Empty string BUT DONT USE! See BUGS -->
+
=cut
use strict;
use warnings;
use vars qw[ $DEBUG $VERSION @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
=pod
+=head1 BUGS
+
+B<Single Tags> e.g. <sqlf:default_value/> Will be parsed as "" and hence also
+false. This is a bit counter intuative for some tags as seeing
+<sqlf:is_nullable /> you might think that it was set when it fact it wouldn't
+be. So for now it is safest not to use them until their handling by the parser
+is sorted out.
+
=head1 TODO
* Support sqf:options.
* Test forign keys are parsed ok.
+ * Sort out sane handling of <foo/> vs <foo></foo> vs it not being there.
* Control over defaulting of non-existant tags.
=head1 AUTHOR
# Tests that;
#
-use Test::More tests => 78;
+use Test::More;
use Test::Exception;
use strict;
# Testing 1,2,3,4...
#=============================================================================
+plan tests => 89;
+
use SQL::Translator;
use SQL::Translator::Schema::Constants;
# Basic
my $tbl = $scma->get_table("Basic");
is $tbl->order, 1, "Basic->order";
-is_deeply( [map {$_->name} $tbl->get_fields],
- [qw/id title description email explicitnulldef explicitemptystring/] ,
- "Table Basic's fields");
+is_deeply( [map {$_->name} $tbl->get_fields], [qw/
+ id title description email explicitnulldef explicitemptystring singletagdef
+/] , "Table Basic's fields");
test_field($tbl->get_field("id"),{
name => "id",
order => 1,
default_value => "",
is_nullable => 1,
});
+test_field($tbl->get_field("singletagdef"),{
+ name => "singletagdef",
+ order => 7,
+ data_type => "varchar",
+ default_value => "",
+ is_nullable => 1,
+});
my @indices = $tbl->get_indices;
is scalar(@indices), 1, "Table basic has 1 index";
extra:
table: Basic
+ singletagdef
+ data_type: varchar
+ size: 0
+ is_nullable: 1
+ default_value:
+ is_primary_key: 0
+ is_unique: 0
+ is_auto_increment: 0
+ is_foreign_key: 0
+ foreign_key_reference:
+ is_valid: 1
+ order: 7
+ extra:
+ table: Basic
+
Indices
titleindex
<sqlf:data_type>varchar</sqlf:data_type>
<sqlf:is_nullable>1</sqlf:is_nullable>
<sqlf:default_value>EMPTY_STRING</sqlf:default_value>
- <sqlf:order>5</sqlf:order>
+ <sqlf:order>6</sqlf:order>
+ </sqlf:field>
+ <sqlf:field>
+ <sqlf:name>singletagdef</sqlf:name>
+ <sqlf:data_type>varchar</sqlf:data_type>
+ <sqlf:is_nullable>1</sqlf:is_nullable>
+ <sqlf:default_value/>
+ <sqlf:order>7</sqlf:order>
</sqlf:field>
</sqlf:fields>