summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerry Hendrikx <ferry.hendrikx@avenir-technology.com>2023-02-28 15:55:15 +1300
committerFerry Hendrikx <ferry.hendrikx@avenir-technology.com>2023-02-28 15:55:15 +1300
commit941443eacd1b105db9dfb9710d363a8eee4d0e6f (patch)
treeb0e1655d18f8e6c88cebcb8cda4429948afdd869
parent75d3a1a154b8e3cd69189f8e9c2bcb6d8600d123 (diff)
Initial commit
-rwxr-xr-xmodules/Rose-DB/lib/Rose/DB/Pg.pm55
-rwxr-xr-xmodules/Rose-DB/t/pg.t10
2 files changed, 65 insertions, 0 deletions
diff --git a/modules/Rose-DB/lib/Rose/DB/Pg.pm b/modules/Rose-DB/lib/Rose/DB/Pg.pm
index e4600f7e..41ba5498 100755
--- a/modules/Rose-DB/lib/Rose/DB/Pg.pm
+++ b/modules/Rose-DB/lib/Rose/DB/Pg.pm
@@ -15,6 +15,43 @@ our $DBD_PG_AFTER_380; # set in refine_dbi_foreign_key_info()
our $Debug = 0;
+
+#
+# Class data
+#
+
+use Rose::Class::MakeMethods::Generic
+(
+ inheritable_scalar =>
+ [
+ '_timestamps_are_inlined',
+ ],
+);
+
+__PACKAGE__->timestamps_are_inlined(0);
+
+
+#
+# Class methods
+#
+
+sub timestamps_are_inlined
+{
+ my($class) = shift;
+
+ if(@_)
+ {
+ my $arg = shift;
+
+ $class->_timestamps_are_inlined($arg);
+
+ return $arg ? 1 : 0;
+ }
+
+ return $class->_timestamps_are_inlined;
+}
+
+
#
# Object data
#
@@ -27,6 +64,7 @@ use Rose::Object::MakeMethods::Generic
],
);
+
#
# Object methods
#
@@ -238,6 +276,13 @@ sub validate_timestamp_keyword
*validate_datetime_keyword = \&validate_timestamp_keyword;
+sub should_inline_timestamp_keyword
+{
+ my($self) = shift;
+ my $class = ref($self) || $self;
+ return ($class->timestamps_are_inlined);
+}
+
sub server_time_zone
{
my($self) = shift;
@@ -791,6 +836,16 @@ This class cannot be used directly. You must use L<Rose::DB> and let its L<new(
Only the methods that are new or have different behaviors than those in L<Rose::DB> are documented here. See the L<Rose::DB> documentation for the full list of methods.
+=head1 CLASS METHODS
+
+=over 4
+
+=item B<timestamps_are_inlined [BOOL]>
+
+Get or set a boolean value that indicates whether or not timestamp keywords should be inline. If C<timestamps_are_inlined> is true, then keywords such as CURRENT_DATESTAMP and CURRENT_TIMESTAMP are inlined in the generated SQL queries. The default is false.
+
+=back
+
=head1 OBJECT METHODS
=over 4
diff --git a/modules/Rose-DB/t/pg.t b/modules/Rose-DB/t/pg.t
index fa4b8e5c..f6ee4d9e 100755
--- a/modules/Rose-DB/t/pg.t
+++ b/modules/Rose-DB/t/pg.t
@@ -197,6 +197,16 @@ foreach my $name (qw(date datetime time timestamp))
}
}
+# Timestamp inlining (default is false)
+
+is($db->should_inline_timestamp_keyword, 0, 'should_inline_timestamp_keyword');
+
+Rose::DB::Pg->timestamps_are_inlined(1);
+is($db->should_inline_timestamp_keyword, 1, 'should_inline_timestamp_keyword');
+
+Rose::DB::Pg->timestamps_are_inlined(0);
+is($db->should_inline_timestamp_keyword, 0, 'should_inline_timestamp_keyword');
+
# Interval values
isa_ok($db->parse_interval('00:00:00'), 'DateTime::Duration');