The Perl Advent Calendar needs more articles for 2022. Submit your idea today!

NAME

SQL::Engine::Grammar::Sqlite - Grammar For SQLite

ABSTRACT

SQL::Engine Grammar For SQLite

SYNOPSIS

  use SQL::Engine::Grammar::Sqlite;

  my $grammar = SQL::Engine::Grammar::Sqlite->new(
    schema => {
      select => {
        from => {
          table => 'users'
        },
        columns => [
          {
            column => '*'
          }
        ]
      }
    }
  );

  # $grammar->execute;

DESCRIPTION

This package provides methods for converting json-sql data structures into SQLite statements.

INHERITS

This package inherits behaviors from:

SQL::Engine::Grammar

LIBRARIES

This package uses type constraints from:

Types::Standard

METHODS

This package implements the following methods:

column_change

  column_change(HashRef $data) : Object

The column_change method generates SQL statements to change a column definition.

column_change example #1
  my $grammar = SQL::Engine::Grammar::Sqlite->new(
    schema => {
      'column-change' => {
        for => {
          table => 'users'
        },
        column => {
          name => 'accessed',
          type => 'datetime',
          nullable => 1
        }
      }
    }
  );

  $grammar->column_change($grammar->schema->{'column-change'});

transaction

  transaction(HashRef $data) : Object

The transaction method generates SQL statements to commit an atomic database transaction.

transaction example #1
  my $grammar = SQL::Engine::Grammar::Sqlite->new(
    schema => {
      'transaction' => {
        queries => [
          {
            'table-create' => {
              name => 'users',
              columns => [
                {
                  name => 'id',
                  type => 'integer',
                  primary => 1
                }
              ]
            }
          }
        ]
      }
    }
  );

  $grammar->transaction($grammar->schema->{'transaction'});

type_binary

  type_binary(HashRef $data) : Str

The type_binary method returns the SQL expression representing a binary data type.

type_binary example #1
  # given: synopsis

  $grammar->type_binary({});

  # blob

type_boolean

  type_boolean(HashRef $data) : Str

The type_boolean method returns the SQL expression representing a boolean data type.

type_boolean example #1
  # given: synopsis

  $grammar->type_boolean({});

  # tinyint(1)

type_char

  type_char(HashRef $data) : Str

The type_char method returns the SQL expression representing a char data type.

type_char example #1
  # given: synopsis

  $grammar->type_char({});

  # varchar

type_date

  type_date(HashRef $data) : Str

The type_date method returns the SQL expression representing a date data type.

type_date example #1
  # given: synopsis

  $grammar->type_date({});

  # date

type_datetime

  type_datetime(HashRef $data) : Str

The type_datetime method returns the SQL expression representing a datetime data type.

type_datetime example #1
  # given: synopsis

  $grammar->type_datetime({});

  # datetime

type_datetime_wtz

  type_datetime_wtz(HashRef $data) : Str

The type_datetime_wtz method returns the SQL expression representing a datetime (and timezone) data type.

type_datetime_wtz example #1
  # given: synopsis

  $grammar->type_datetime_wtz({});

  # datetime

type_decimal

  type_decimal(HashRef $data) : Str

The type_decimal method returns the SQL expression representing a decimal data type.

type_decimal example #1
  # given: synopsis

  $grammar->type_decimal({});

  # numeric

type_double

  type_double(HashRef $data) : Str

The type_double method returns the SQL expression representing a double data type.

type_double example #1
  # given: synopsis

  $grammar->type_double({});

  # float

type_enum

  type_enum(HashRef $data) : Str

The type_enum method returns the SQL expression representing a enum data type.

type_enum example #1
  # given: synopsis

  $grammar->type_enum({ options => ['light', 'dark'] });

  # varchar

type_float

  type_float(HashRef $data) : Str

The type_float method returns the SQL expression representing a float data type.

type_float example #1
  # given: synopsis

  $grammar->type_float({});

  # float

type_integer

  type_integer(HashRef $data) : Str

The type_integer method returns the SQL expression representing a integer data type.

type_integer example #1
  # given: synopsis

  $grammar->type_integer({});

  # integer

type_integer_big

  type_integer_big(HashRef $data) : Str

The type_integer_big method returns the SQL expression representing a big-integer data type.

type_integer_big example #1
  # given: synopsis

  $grammar->type_integer_big({});

  # integer

type_integer_big_unsigned

  type_integer_big_unsigned(HashRef $data) : Str

The type_integer_big_unsigned method returns the SQL expression representing a big unsigned integer data type.

type_integer_big_unsigned example #1
  # given: synopsis

  $grammar->type_integer_big_unsigned({});

  # integer

type_integer_medium

  type_integer_medium(HashRef $data) : Str

The type_integer_medium method returns the SQL expression representing a medium integer data type.

type_integer_medium example #1
  # given: synopsis

  $grammar->type_integer_medium({});

  # integer

type_integer_medium_unsigned

  type_integer_medium_unsigned(HashRef $data) : Str

The type_integer_medium_unsigned method returns the SQL expression representing a unsigned medium integer data type.

type_integer_medium_unsigned example #1
  # given: synopsis

  $grammar->type_integer_medium_unsigned({});

  # integer

type_integer_small

  type_integer_small(HashRef $data) : Str

The type_integer_small method returns the SQL expression representing a small integer data type.

type_integer_small example #1
  # given: synopsis

  $grammar->type_integer_small({});

  # integer

type_integer_small_unsigned

  type_integer_small_unsigned(HashRef $data) : Str

The type_integer_small_unsigned method returns the SQL expression representing a unsigned small integer data type.

type_integer_small_unsigned example #1
  # given: synopsis

  $grammar->type_integer_small_unsigned({});

  # integer

type_integer_tiny

  type_integer_tiny(HashRef $data) : Str

The type_integer_tiny method returns the SQL expression representing a tiny integer data type.

type_integer_tiny example #1
  # given: synopsis

  $grammar->type_integer_tiny({});

  # integer

type_integer_tiny_unsigned

  type_integer_tiny_unsigned(HashRef $data) : Str

The type_integer_tiny_unsigned method returns the SQL expression representing a unsigned tiny integer data type.

type_integer_tiny_unsigned example #1
  # given: synopsis

  $grammar->type_integer_tiny_unsigned({});

  # integer

type_integer_unsigned

  type_integer_unsigned(HashRef $data) : Str

The type_integer_unsigned method returns the SQL expression representing a unsigned integer data type.

type_integer_unsigned example #1
  # given: synopsis

  $grammar->type_integer_unsigned({});

  # integer

type_json

  type_json(HashRef $data) : Str

The type_json method returns the SQL expression representing a json data type.

type_json example #1
  # given: synopsis

  $grammar->type_json({});

  # text

type_number

  type_number(HashRef $data) : Str

The type_number method returns the SQL expression representing a number data type.

type_number example #1
  # given: synopsis

  $grammar->type_number({});

  # integer

type_string

  type_string(HashRef $data) : Str

The type_string method returns the SQL expression representing a string data type.

type_string example #1
  # given: synopsis

  $grammar->type_string({});

  # varchar

type_text

  type_text(HashRef $data) : Str

The type_text method returns the SQL expression representing a text data type.

type_text example #1
  # given: synopsis

  $grammar->type_text({});

  # text

type_text_long

  type_text_long(HashRef $data) : Str

The type_text_long method returns the SQL expression representing a long text data type.

type_text_long example #1
  # given: synopsis

  $grammar->type_text_long({});

  # text

type_text_medium

  type_text_medium(HashRef $data) : Str

The type_text_medium method returns the SQL expression representing a medium text data type.

type_text_medium example #1
  # given: synopsis

  $grammar->type_text_medium({});

  # text

type_time

  type_time(HashRef $data) : Str

The type_time method returns the SQL expression representing a time data type.

type_time example #1
  # given: synopsis

  $grammar->type_time({});

  # time

type_time_wtz

  type_time_wtz(HashRef $data) : Str

The type_time_wtz method returns the SQL expression representing a time (and timezone) data type.

type_time_wtz example #1
  # given: synopsis

  $grammar->type_time_wtz({});

  # time

type_timestamp

  type_timestamp(HashRef $data) : Str

The type_timestamp method returns the SQL expression representing a timestamp data type.

type_timestamp example #1
  # given: synopsis

  $grammar->type_timestamp({});

  # datetime

type_timestamp_wtz

  type_timestamp_wtz(HashRef $data) : Str

The type_timestamp_wtz method returns the SQL expression representing a timestamp (and timezone) data type.

type_timestamp_wtz example #1
  # given: synopsis

  $grammar->type_timestamp_wtz({});

  # datetime

type_uuid

  type_uuid(HashRef $data) : Str

The type_uuid method returns the SQL expression representing a uuid data type.

type_uuid example #1
  # given: synopsis

  $grammar->type_uuid({});

  # varchar

wrap

  wrap(Str $name) : Str

The wrap method returns a SQL-escaped string.

wrap example #1
  # given: synopsis

  $grammar->wrap('field');

  # "field"

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues