NAME

Doodle::Grammar

ABSTRACT

Doodle Grammar Base Class

SYNOPSIS

use Doodle::Grammar;

my $self = Doodle::Grammar->new;

DESCRIPTION

This package determines how command objects should be interpreted to produce the correct DDL statements.

LIBRARIES

This package uses type constraints from:

Doodle::Library

ATTRIBUTES

This package has the following attributes:

name

name(Str)

This attribute is read-only, accepts (Str) values, and is optional.

METHODS

This package implements the following methods:

create_column

create_column(Command $command) : Str

Generate SQL statement for column-create Command.

create_column example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $column = $ddl->table('users')->column('id');
my $command = $column->create;

my $create_column = $self->create_column($command);

create_constraint

create_constraint(Column $column) : Str

Returns the SQL statement for the create constraint command.

create_constraint example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $relation = $ddl->table('emails')->relation('user_id', 'users', 'id');
my $command = $relation->create;

$self->create_constraint($command);

create_index

create_index(Command $command) : Str

Generate SQL statement for index-create Command.

create_index example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $index = $ddl->table('users')->index(columns => ['is_admin']);
my $command = $index->create;

my $create_index = $self->create_index($command);

create_schema

create_schema(Command $command) : Str

Generate SQL statement for schema-create Command.

create_schema example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $schema = $ddl->schema('app');
my $command = $schema->create;

my $create_schema = $self->create_schema($command);

create_table

create_table(Command $command) : Str

Generate SQL statement for table-create Command.

create_table example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $table = $ddl->table('users');
my $command = $table->create;

my $create_table = $self->create_table($command);

delete_column

delete_column(Command $command) : Str

Generate SQL statement for column-delete Command.

delete_column example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $column = $ddl->table('users')->column('id');
my $command = $column->delete;

my $delete_column = $self->delete_column($command);

delete_constraint

delete_constraint(Column $column) : Str

Returns the SQL statement for the delete constraint command.

delete_constraint example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $relation = $ddl->table('emails')->relation('user_id', 'users', 'id');
my $command = $relation->delete;

$self->delete_constraint($command);

delete_index

delete_index(Command $command) : Str

Generate SQL statement for index-delete Command.

delete_index example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $index = $ddl->table('users')->index(columns => ['is_admin']);
my $command = $index->delete;

my $delete_index = $self->delete_index($command);

delete_schema

delete_schema(Command $command) : Str

Generate SQL statement for schema-delete Command.

delete_schema example #1
# given: synopsis

my $ddl = Doodle->new;
my $schema = $ddl->schema('app');
my $command = $schema->delete;

my $delete_schema = $self->delete_schema($command);

delete_table

delete_table(Command $command) : Str

Generate SQL statement for table-delete Command.

delete_table example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $table = $ddl->table('users');
my $command = $table->delete;

my $delete_table = $self->delete_table($command);

exception

exception(Str $message) : Any

Throws an exception using Carp confess.

exception example #1
# given: synopsis

$self->exception('Oops');

execute

execute(Command $command) : Statement

Processed the Command and returns a Statement object.

execute example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $column = $ddl->table('users')->column('id');
my $command = $column->create;

my $statement = $self->execute($command);

rename_column

rename_column(Command $command) : Str

Generate SQL statement for column-rename Command.

rename_column example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $column = $ddl->table('users')->column('id');
my $command = $column->rename('uuid');

my $rename_column = $self->rename_column($command);

rename_table

rename_table(Command $command) : Str

Generate SQL statement for table-rename Command.

rename_table example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $table = $ddl->table('users');
my $command = $table->rename('people');

my $rename_table = $self->rename_table($command);

render

render(Command $command) : Str

Returns the SQL statement for the given Command.

render example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $schema = $ddl->schema('app');
my $command = $schema->create;
my $template = 'create schema {schema_name}';

my $sql = $self->render($template, $command);

update_column

update_column(Any @args) : Str

Generate SQL statement for column-update Command.

update_column example #1
# given: synopsis

use Doodle;

my $ddl = Doodle->new;
my $column = $ddl->table('users')->column('id')->integer_small;
my $command = $column->update;

my $update_column = $self->update_column($command);

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