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?
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
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.