DB-Object

 view release on metacpan or  search on metacpan

lib/DB/Object/SQLite/Tables.pm  view on Meta::CPAN

=head1 VERSION

    v1.0.0

=head1 DESCRIPTION

This is a SQLite table object class.

=head1 METHODS

=head2 create

This creates a table.

It takes some array reference data containing the columns definitions, some optional parameters and a statement handler.

If a statement handler is provided, then no need to provide an array reference of columns definition. The columns definition will be taken from the statement handler. However, at least either one of them needs to be provided to set the columns defini...

Possible parameters are:

=over 4

=item * C<comment>

=item * C<password>

=item * C<temporary>

If provided, this will create a temporary table.

=back

This will return an error if the table already exists, so best to check beforehand with L</exists>.

Upon success, it will return the new statement to create the table. However, if L</create> is called in void context, then the statement is executed right away and returned.

=head2 create_info

This returns the create info for the current table object as a string representing the sql script necessary to recreate the table.

=head2 exists

Returns true if the current table exists, or false otherwise.

=head2 lock

Table lock is unsupported in SQLite and this will return an error.

=head2 on_conflict

A convenient wrapper to L<DB::Object::Postgres::Query/on_conflict>

This feature is available in SQLite since version 3.35.0 released on 2021-03-12. If your version of SQLite is anterior, this will return an error.

=head2 rename

Provided with a new table name, and this will prepare the necessary query to rename the table and return the statement handler.

If it is called in void context, the statement handler is executed immediately.

    # Get the prefs table object
    my $tbl = $dbh->pref;
    $tbl->rename( 'prefs' );
    # Would issue a statement handler for the query: ALTER TABLE pref RENAME TO prefs

See L<SQLite documentation for more information|https://www.sqlite.org/lang_altertable.html>

=head2 structure

This returns in list context an hash and in scalar context an hash reference of the table structure.

The hash, or hash reference returned contains the column name and its definition.

This method will also set the following object properties:

=over 4

=item * L<DB::Object::Tables/type>

The table type.

=item * C<default>

A column name to default value hash reference

=item * C<fields>

A column name to field position (integer) hash reference

=item * C<null>

A column name to a boolean representing whether the column is nullable or not.

=item * L<DB::Object::Tables/primary>

An array reference of column names that are used as primary key for the table.

=item * C<structure>

A column name to its sql definition

=item * C<types>

A column name to column data type hash reference

=back

=head2 table_info

This is an alias for L<DB::Object::SQLite/table_info>

=head2 unlock

This returns an error as C<unlock> is unsupported in SQLite

=head1 SEE ALSO

L<perl>

=head1 AUTHOR

Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>

=head1 COPYRIGHT & LICENSE



( run in 0.531 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )