can't the schema diff utility include a function such as  
compare_defaults(a, b) ?   a ColumnDefault isn't really like a SQL  
expression object so the __eq__()/__ne__() seems inappropriate (in  
general, overriding __eq__() is an endeavor to be taken on carefully,  
since it heavily changes the behavior of that object when used in  
lists and such).


On Jun 12, 2008, at 3:44 PM, Yannick Gingras wrote:

> Greeting Alchemists,
>  in order to implement schema diffing, it would be nice if two similar
> ColumnDefault objects would be comparable as such.  I attach a path to
> implement such test.  Would it make sense to add this support in
> Alchemy's core or should a schema diffing library add it through
> monkey patching?
>
> -- 
> Yannick Gingras
>
> >
> Index: lib/sqlalchemy/schema.py
> ===================================================================
> --- lib/sqlalchemy/schema.py    (revision 4842)
> +++ lib/sqlalchemy/schema.py    (working copy)
> @@ -970,2 +970,2 @@
>             return "column_default"
>     __visit_name__ = property(_visit_name)
>
> +    def __eq__(self, other):
> +        if self.__class__ != other.__class__:
> +            return NotImplemented
> +        if callable(self.arg) and callable(other.arg):
> +            return NotImplemented
> +        return self.arg == other.arg
> +
> +    def __ne__(self, other):
> +        return not self.__eq__(other)
> +
>     def __repr__(self):
>         return "ColumnDefault(%s)" % repr(self.arg)
>
> +
> class Sequence(DefaultGenerator):
>     """Represents a named database sequence."""
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to