<br><br><div class="gmail_quote">On Mon, Nov 12, 2012 at 11:22 AM, Monty Taylor <span dir="ltr"><<a href="mailto:mordred@inaugust.com" target="_blank">mordred@inaugust.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
<br>
On 11/12/2012 08:09 AM, Jay Pipes wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 11/12/2012 07:55 AM, Ionuț Arțăriși wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I submitted a patch for review last week[1] which started a discussion<br>
about implementing sqlalchemy dialect specific datatypes<br>
(e.g. postgresql, mysql etc.).<br>
<br>
I think it would be great to abstract some common datatypes (such as for<br>
ip addresses) so we can then add custom validations or use different<br>
backend datatypes where that makes sense.<br>
</blockquote>
<br>
I also think this is a good idea. It's painful to see CHAR(32) used for<br>
things like UUIDs stored as hex string values and VARCHAR(255) used to<br>
store IPv4 addresses, which are simply unsigned 4-byte integers.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The way the IPAddress is implemented should be pretty straightforward and<br>
very backwards compatible (the INET datatype acts as a string for basic<br>
operations). Just defining a new datatype:<br>
<br>
IPAddress = lambda: String(255).with_variant(<u></u>postgresql.INET(),<br>
'postgresql')<br>
</blockquote>
<br>
Might be good to name it IPv4Address instead of IPAddress, even though<br>
PostgreSQL's INET type supports both.<br>
<br>
With MySQL, you can use the INET_ATON() and INET_NTOA() functions (in<br>
SQLAlchemy' func.inet_aton as well...) to do the conversion to and from<br>
the underlying unsigned integer and extend an existing SQLAlchemy data<br>
type as shown here:<br>
<br>
<a href="http://docs.sqlalchemy.org/en/rel_0_7/core/types.html#augmenting-existing-types" target="_blank">http://docs.sqlalchemy.org/en/<u></u>rel_0_7/core/types.html#<u></u>augmenting-existing-types</a><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
which can then be used instead of the string like so:<br>
<br>
access_ip_v4 = Column(IPAddress())<br>
<br>
I guess now there's the question of where we want to store these<br>
custom dataypes' implementations. Would it be enough to have a datatypes.py<br>
module in there and have all our custom types inside?<br>
</blockquote>
<br>
That would be fine with me -- especially if it was in Oslo eventually :)<br>
</blockquote>
<br></div></div>
Don't forget - you _might_ be able to land something like that upstream in sqlalchemy too.<br></blockquote><div><br></div><div>+1</div><div><br></div><div>That seems like a better place for this than in just our OpenStack libraries.</div>
<div><br></div><div>Doug</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Other than that- I agree.<span class="HOEnZb"><font color="#888888"><br>
<br>
Monty</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<u></u>_________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.<u></u>org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/<u></u>cgi-bin/mailman/listinfo/<u></u>openstack-dev</a><br>
</div></div></blockquote></div><br>