Declaring indexes with hobofields: Part II

6 views
Skip to first unread message

Owen

unread,
Aug 28, 2009, 3:58:27 PM8/28/09
to Hobo Users
The last thread was a great discussion. I would like to clarify my
understanding for your feedback using the example below:

(Hobo doesn't use the" :unique => true" or ":required=> true", so why
":index = true" instead of ":indexed" ?)

<!-- ====== The Hobo Way ====== -->
fields do

<!-- ====== short-and-sweet wayto declare indexes ====== -->
last_name :string, :required, :indexed
state_code :string, :required, :unique, :length =>
2, :indexed

end

<!-- ====== Foreign keys will NOT be indexed:====== -->
has_many :cars, :index => false

<!-- ====== Foreign keys WILL be indexed:====== -->
has_many :posts

<!-- ====== Mult-field index:====== -->
index [:last_name, :state_code], :name =>
"contacts_name_plus_state_index"


Owen

unread,
Aug 28, 2009, 4:16:48 PM8/28/09
to Hobo Users
When can we have this to test? : -)

Matt Jones

unread,
Aug 28, 2009, 4:22:31 PM8/28/09
to hobo...@googlegroups.com

On Aug 28, 2009, at 3:58 PM, Owen wrote:

>
> The last thread was a great discussion. I would like to clarify my
> understanding for your feedback using the example below:
>
> (Hobo doesn't use the" :unique => true" or ":required=> true", so why
> ":index = true" instead of ":indexed" ?)

Hmmm.. must have been a while since I used those options. I was
assuming that they worked like :primary_content, :name, :login
and :creator. Maybe they should?

> <!-- ====== The Hobo Way ====== -->
> fields do
>
> <!-- ====== short-and-sweet wayto declare indexes ====== -->
> last_name :string, :required, :indexed
> state_code :string, :required, :unique, :length =>
> 2, :indexed

The state_code example doesn't parse - once the implicit hash literal
is started, it's not possible to have other non-hashy args.

Also, this loses the ability to have a custom name for the index.

> end
>
> <!-- ====== Foreign keys will NOT be indexed:====== -->
> has_many :cars, :index => false
>
> <!-- ====== Foreign keys WILL be indexed:====== -->
> has_many :posts

These should both be belongs_to (which declares the key) rather than
has_many, but makes sense otherwise. Note that the index naming is
also missing here.

--Matt Jones

Matt Jones

unread,
Aug 28, 2009, 4:23:32 PM8/28/09
to hobo...@googlegroups.com
It's looking like I'll have some time this weekend and next, so
hopefully pretty soon...

--Matt Jones

Owen

unread,
Aug 29, 2009, 2:06:47 PM8/29/09
to Hobo Users
Thanks, Matt. Looking forward to testing this out when you are
ready. We'll try it out on Oracle as well....
Reply all
Reply to author
Forward
0 new messages