Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

inserting a link works now

  • Loading branch information...
commit 324bc6299a1da327cf3b240c37176c43fc1bd70d 1 parent 423bd84
@moritz authored
View
4 lib/Soonish/Common.pm
@@ -4,9 +4,9 @@ use Soonish::Table;
# TODO: Really need a better name for this;
role Soonish::Common does Soonish::Table {
has $.entered-by;
- has $.creation-date = now;
+# has $.creation-date = now;
# schould really be multiple links, but the "ORM" can't handle that yet
- has $.link;
+# has $.link;
}
# vim: ft=perl6
View
7 lib/Soonish/Table.pm
@@ -1,7 +1,9 @@
use v6;
role Soonish::Table {
- has Int $.id;
+ has Int $.id is rw;
+
+ method !set_id($id) { $!id = $id }
has $._schema;
method table {
@@ -36,9 +38,8 @@ role Soonish::Table {
else {
$sth.execute(%a.values.map({ $_ ~~ Soonish::Table ?? .id || .insert.id !! $_}));
}
- ($id) = $sth.fetchrow;
- $sth.finish;
$.id = $id;
+ $sth.finish;
self;
}
View
3  schema.sql
@@ -3,5 +3,6 @@ DROP TABLE IF EXISTS link CASCADE;
CREATE TABLE link (
id SERIAL primary key,
url VARCHAR(255) NOT NULL,
- text VARCHAR(255) NOT NULL
+ text VARCHAR(255) NOT NULL,
+ "entered-by" VARCHAR(255)
);
View
1  t.pl
@@ -13,6 +13,7 @@
url => 'http://www.markknopfler.com/tour/',
text => 'Mark Knopfler on Tour',
_schema => $s,
+ entered-by => 'moritz',
);
$link.insert-or-update;
Please sign in to comment.
Something went wrong with that request. Please try again.