| 1 | ##---------------------------------------------------------------------------- | ||
| 2 | ## Database Object Interface - ~/lib/DB/Object/Fields/Overloaded.pm | ||
| 3 | ## Version v0.2.0 | ||
| 4 | ## Copyright(c) 2023 DEGUEST Pte. Ltd. | ||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||
| 6 | ## Created 2020/01/01 | ||
| 7 | ## Modified 2026/03/22 | ||
| 8 | ## All rights reserved | ||
| 9 | ## | ||
| 10 | ## This program is free software; you can redistribute it and/or modify it | ||
| 11 | ## under the same terms as Perl itself. | ||
| 12 | ##---------------------------------------------------------------------------- | ||
| 13 | package DB::Object::Fields::Overloaded; | ||
| 14 | BEGIN | ||
| 15 | { | ||
| 16 | use strict; | ||
| 17 | use warnings; | ||
| 18 | warnings::register_categories( 'DB::Object' ); | ||
| 19 | use parent qw( DB::Object::Query::Element ); | ||
| 20 | use vars qw( $VERSION $EXCEPTION_CLASS ); | ||
| 21 | use overload ( | ||
| 22 | '""' => sub{ return( $_[0]->{expression} ) }, | ||
| 23 | 'bool' => sub{1}, | ||
| 24 | fallback => 1, | ||
| 25 | ); | ||
| 26 | our $EXCEPTION_CLASS = $DB::Object::EXCEPTION_CLASS; | ||
| 27 | our $VERSION = 'v0.2.0'; | ||
| 28 | }; | ||
| 29 | |||
| 30 | use strict; | ||
| 31 | use warnings; | ||
| 32 | |||
| 33 | sub init | ||
| 34 | { | ||
| 35 | my $self = shift( @_ ); | ||
| 36 | $self->{expression} = undef; | ||
| 37 | $self->{_init_strict_use_sub} = 1; | ||
| 38 | $self->{_exception_class} = $EXCEPTION_CLASS; | ||
| 39 | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||
| 40 | return( $self ); | ||
| 41 | } | ||
| 42 | |||
| 43 | # sub binded { return( shift->{binded} ); } | ||
| 44 | |||
| 45 | # For example, if a placeholder was $1 (PostgreSQL), or ?1 (SQLite), the binded_offset value would be 1 | ||
| 46 | # sub binded_offset { return( shift->{binded_offset} ); } | ||
| 47 | |||
| 48 | sub expression { return( shift->_set_get_scalar( 'expression', @_ ) ); } | ||
| 49 | |||
| 50 | 1; | ||
| 51 | # NOTE: POD | ||
| 52 | __END__ |