I came across this post from Ilya Grigorik on Hacker News yesterday and I figured I just had to implement this in Drizzle now with the new query rewriting interface that I mentioned yesterday. The awesome thing about Drizzle is that I can try all these ideas out easily by just implementing a plugin.
Any SQL statements we want to use on our schema-free constructs, we have to prefix with the string 'nos'. With that said, here is a session demonstrating this query rewriting plugin:
Your Drizzle connection id is 2
Server version: 7 Source distribution (schema-less)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

drizzle> use test;
Database changed
drizzle> nos create table widgets;
Query OK, 0 rows affected (0.06 sec)

drizzle> nos insert into widgets (id,name) values ('a', 'apple');
Query OK, 1 row affected (0.19 sec)

drizzle> nos insert into widgets (id,name,type) values ('b', 'blackberry', 'phone');
Query OK, 1 row affected (0.21 sec)

drizzle> nos select * from widgets;
+------+------------+-------+
| id   | name       | type  |
+------+------------+-------+
| a    | apple      | NULL  | 
| b    | blackberry | phone | 
+------+------------+-------+
2 rows in set (0 sec)

drizzle> nos select * from widgets where id = 'a';
+------+-------+------+
| id   | name  | type |
+------+-------+------+
| a    | apple | NULL | 
+------+-------+------+
1 row in set (0 sec)

drizzle>

The code for this is available on Launchpad (lp:~posulliv/drizzle/schema-less). I threw this together in a few hours today for fun so it is what it is.

blog comments powered by Disqus

Published

02 March 2010

Category

drizzle