Field, etc. declaration syntax

2 views
Skip to first unread message

Adam Atlas

unread,
Jul 27, 2007, 10:09:08 AM7/27/07
to SQLElixir
I'm sorry if this has already been discussed before; I searched and
couldn't find much.

I was wondering why Elixir does not support the fieldname =
ColumnType(...) style of field declaration (while ActiveMapper and
TurboEntity did). Comparing these two instances (based on the example
on the site)...

class User(Entity):
has_field('user_id', Integer, primary_key=True)
has_field('user_name', Unicode(16), unique=True)
has_field('email_address', Unicode(255), unique=True)
has_field('display_name', Unicode(255))
has_field('password', Unicode(40))
has_field('created', DateTime, default=datetime.now)

class User(Entity):
user_id = Integer(primary_key=True)
user_name = Unicode(16, unique=True)
email_address = Unicode(255, unique=True)
display_name = Unicode(255)
password = Unicode(40)
created = DateTime(default=datetime.now)

...I think the latter looks much nicer and more Pythonic. It seems
like if it existed, it would be the One Obvious Way. I don't even see
how has_field or with_fields have any advantages over this.

Thoughts?

Waylan Limberg

unread,
Jul 27, 2007, 10:52:30 AM7/27/07
to sqle...@googlegroups.com
I recall this question being asked a few times when Elixir was first
released (perhaps even by myself). Then, we got a nice introduction to
statements [1] and all (most) those questions went away. You see,
everything in Elixir is a DSL statement, which makes it very simple,
yet powerful. I suppose it's would be possible to alter the syntax,
but see the first half of this previous discussion [2] before pressing
on.

Hope that answers your questions.

[1]: http://cleverdevil.org/computing/52/
[2]:http://groups.google.com/group/sqlelixir/browse_thread/thread/29dcb0ee987952d1/


--
----
Waylan Limberg
way...@gmail.com

Adam Atlas

unread,
Aug 3, 2007, 11:13:39 PM8/3/07
to SQLElixir

On Jul 27, 10:52 am, "Waylan Limberg" <way...@gmail.com> wrote:
> I recall this question being asked a few times when Elixir was first
> released (perhaps even by myself). Then, we got a nice introduction to
> statements [1] and all (most) those questions went away. You see,
> everything in Elixir is a DSL statement, which makes it very simple,
> yet powerful. I suppose it's would be possible to alter the syntax,
> but see the first half of this previous discussion [2] before pressing
> on.

Perhaps assignments could be a special case of statements? I can think
of uses for them other than declaring columns, actually. And I can
think of a way that support for these assignment-declarations could be
generically supported just like plain statements are now.

Reply all
Reply to author
Forward
0 new messages