Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added more properties on columns
  • Loading branch information
gja committed Jun 4, 2011
1 parent 0c4b2a0 commit c2fdb40
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Expand Up @@ -5,6 +5,6 @@ Downpour is a gem to connect and query a Drizzle or MySql database using the lib
== TODO
* Do not maintain a list of pending queries and connections in ruby. Mark and sweep. Is this a good idea
* Actually honor some options passed in to drizzle_con_create
* Get column info and do stuff
* Get column type and do stuff.
* Create a rails plugin
* Result, Column does not have a context. Memory Leak?
26 changes: 26 additions & 0 deletions ext/downpour/column.c
Expand Up @@ -9,7 +9,20 @@
return conversion(drizzle_column_##foo(self_ptr));\
}

attr_string(catalog);
attr_string(db);
attr_string(table);
attr_string(orig_table);
attr_string(name);
attr_string(orig_name);
// charset
attr(column_size, UINT2NUM);
attr(max_size, INT2NUM);
//column type
//column_type_drizzle
//flags
attr(decimals, UINT2NUM);
//default_value

VALUE downpour_column_constructor(drizzle_column_st *self_ptr, VALUE result)
{
Expand All @@ -19,5 +32,18 @@ VALUE downpour_column_constructor(drizzle_column_st *self_ptr, VALUE result)
void init_drizzle_column()
{
DrizzleColumn = drizzle_gem_create_class_with_private_constructor("Column", rb_cObject);
define_attr(catalog);
define_attr(db);
define_attr(table);
define_attr(orig_table);
define_attr(name);
define_attr(orig_name);
// charset
define_attr(column_size);
define_attr(max_size);
//column type
//column_type_drizzle
//flags
define_attr(decimals);
//default_value
}
12 changes: 10 additions & 2 deletions spec/downpour/column_spec.rb
Expand Up @@ -3,7 +3,7 @@
before(:each) do
@status = Downpour.create
@conn = create_connection(@status)
@results = @conn.query "select * from Test2"
@results = @conn.query "select id, name as newName from Test2"
end

it "should fetch all columns" do
Expand All @@ -16,7 +16,15 @@

it "should fetch column name" do
@results.columns[0].name.should == "id"
@results.columns[1].name.should == "name"
@results.columns[1].name.should == "newName"
end

it "should fetch the original name from table" do
@results.columns[1].orig_name.should == "name"
end

it "should have table name set on column" do
@results.columns[0].table.should == "Test2"
end

it "should not buffer after reading columns" do
Expand Down

0 comments on commit c2fdb40

Please sign in to comment.