Escape quotes in string values in producers
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Generator / Role / DDL.pm
index 1691467..83c8647 100644 (file)
@@ -1,7 +1,15 @@
 package SQL::Translator::Generator::Role::DDL;
 
-# AUTHOR: Arthur Axel fREW Schmidt
-# Copyright: Same as Perl 5
+=head1 NAME
+
+SQL::Translator::Generator::Role::DDL - Role implementing common parts of
+DDL generation.
+
+=head1 DESCRIPTION
+
+I<documentation volunteers needed>
+
+=cut
 
 use Moo::Role;
 use SQL::Translator::Utils qw(header_comment);
@@ -12,6 +20,7 @@ requires '_build_numeric_types';
 requires '_build_unquoted_defaults';
 requires '_build_sizeless_types';
 requires 'quote';
+requires 'quote_string';
 
 has type_map => (
    is => 'lazy',
@@ -73,7 +82,7 @@ sub field_default {
   if (ref $default) {
       $default = $$default;
   } elsif (!($self->numeric_types->{lc($field->data_type)} && Scalar::Util::looks_like_number ($default))) {
-     $default = "'$default'";
+      $default = $self->quote_string($default);
   }
   return ( "DEFAULT $default" )
 }
@@ -109,3 +118,19 @@ sub nullable { 'NULL' }
 sub header_comments { header_comment() . "\n" if $_[0]->add_comments }
 
 1;
+
+=head1 AUTHORS
+
+See the included AUTHORS file:
+L<http://search.cpan.org/dist/SQL-Translator/AUTHORS>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2012 the SQL::Translator L</AUTHORS> as listed above.
+
+=head1 LICENSE
+
+This code is free software and may be distributed under the same terms as Perl
+itself.
+
+=cut