| 1 | package SQL::Engine::Builder::Update; | ||
| 2 | |||
| 3 | use 5.014; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | use registry; | ||
| 9 | use routines; | ||
| 10 | |||
| 11 | use Data::Object::Class; | ||
| 12 | use Data::Object::ClassHas; | ||
| 13 | |||
| 14 | extends 'SQL::Engine::Builder'; | ||
| 15 | |||
| 16 | use SQL::Validator; | ||
| 17 | |||
| 18 | our $VERSION = '0.02'; # VERSION | ||
| 19 | |||
| 20 | # ATTRIBUTES | ||
| 21 | |||
| 22 | has for => ( | ||
| 23 | is => 'ro', | ||
| 24 | isa => 'HashRef', | ||
| 25 | req => 1 | ||
| 26 | ); | ||
| 27 | |||
| 28 | has columns => ( | ||
| 29 | is => 'ro', | ||
| 30 | isa => 'ArrayRef[HashRef]', | ||
| 31 | req => 1 | ||
| 32 | ); | ||
| 33 | |||
| 34 | has where => ( | ||
| 35 | is => 'ro', | ||
| 36 | isa => 'ArrayRef[HashRef]', | ||
| 37 | opt => 1 | ||
| 38 | ); | ||
| 39 | |||
| 40 | has returning => ( | ||
| 41 | is => 'ro', | ||
| 42 | isa => 'ArrayRef[HashRef]', | ||
| 43 | opt => 1 | ||
| 44 | ); | ||
| 45 | |||
| 46 | # METHODS | ||
| 47 | |||
| 48 | method data() { | ||
| 49 | my $schema = {}; | ||
| 50 | |||
| 51 | if ($self->for) { | ||
| 52 | $schema->{"for"} = $self->for; | ||
| 53 | } | ||
| 54 | |||
| 55 | if ($self->columns) { | ||
| 56 | $schema->{"columns"} = $self->columns; | ||
| 57 | } | ||
| 58 | |||
| 59 | if ($self->where) { | ||
| 60 | $schema->{"where"} = $self->where; | ||
| 61 | } | ||
| 62 | |||
| 63 | if ($self->returning) { | ||
| 64 | $schema->{"returning"} = $self->returning; | ||
| 65 | } | ||
| 66 | |||
| 67 | return { | ||
| 68 | update => $schema | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | 1; |