Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Squerl] changed the Database.create_table API

Matt-W++ for the feedback.
  • Loading branch information...
commit 756685b866116a3064aa83553d3af83dbe487a7a 1 parent a22061c
@masak authored
Showing with 9 additions and 6 deletions.
  1. +4 −1 lib/Squerl.pm
  2. +5 −5 t/squerl/01-sqlite-write.t
View
5 lib/Squerl.pm
@@ -346,7 +346,10 @@ class Squerl::Database {
method create_table($_: *@args) {
my $table-name = @args[0];
- my $columns = join ', ', gather for @args[1..^*] -> $type, $name {
+ my $columns = join ', ', gather for @args[1..^*] {
+ die "Expected a Pair, got a {.WHAT}"
+ unless $_ ~~ Pair;
+ my ($name, $type) = .key, .value;
given $type.lc {
when 'primary_key' { take "$name INTEGER PRIMARY KEY ASC" }
when 'int'|'integer' { take "$name INTEGER" }
View
10 t/squerl/01-sqlite-write.t
@@ -6,11 +6,11 @@ use Squerl;
unlink (my $file = 't/squerl/posts.db');
my $DB = Squerl.sqlite($file);
-$DB.create_table: <posts
- primary_key id
- Int user_id
- String name
->;
+$DB.create_table: 'posts',
+ 'id' => 'primary_key',
+ 'user_id' => 'Int',
+ 'name' => 'String',
+;
#my $posts = $DB<posts>;
my $posts = $DB.from('posts');
Please sign in to comment.
Something went wrong with that request. Please try again.