Hi,
I am using postgresql and I prefer my VARCHAR columns not to have a length limit. Is there any particular reason why max_length arg to fields is required. If for compatibility with other database backends we can have some sane default if it is None.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b6d01012-93bb-41b6-9065-c1d360e63b61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/2A451482-2DDD-42CE-895B-55E1FF1026D3%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/DA725AF8-A7CA-449F-B92A-0BCCDB124AD6%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/FE33D41D-30F7-497F-9E2D-4ABC396E4BE6%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/15D5715A-3EF5-4CC0-830C-8EB714424335%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/95E76678-2FAB-46B4-B830-0AC877886EE4%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.
On Sep 21, 2015, at 7:22 PM, Shai Berger <sh...@platonix.com> wrote:
> I'd solve the "need to specify" issue by setting a default that is
> intentionally smaller than the smallest (core) backend limitation, say 128.
I'd be OK with that. Not wild, because I think that having to specify max_length is good discipline, but not everyone likes oatmeal, either. :)
> I"d make an "unlimited length text field" a new type of field, explicitly not
> supported on MySql and Oracle; and I'd suggest that it can live outside core
> for a while. so we may get an impression of how popular it really is.
We kind of have that: TextField. The problem is that TextField has very different performance characteristics and implementation details on PostgreSQL vs MySQL and Oracle. I don't think we need another: If you know you are running on PostgreSQL, you just use TextField, and if you are either targeting a different database, or writing one that runs on multiple ones, you probably want CharField with a specific length.
--
-- Christophe Pettus
x...@thebuild.com
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/3542EAF7-C2EB-4A4B-94F4-8C7A9EC4AC4E%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.
Aymeric, thanks for clarification, my bad I missed that one. We will be using max_length=255 or 128 for the default as Shia proposed.
BTW how is this handled by integer_ranges on per database backend? Also, using checks_framework can we validate this setting?
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/2FF1A3B1-0167-4E52-9F99-EB5BDD6B81C5%40polytechnique.org.
We will be using max_length=255 or 128 for the default as Shia proposed.
BTW how is this handled by integer_ranges on per database backend?
Ok, I'll wait for other contributors to react.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/ECA9C917-6FB8-467B-97DC-9E4FE970BC9B%40polytechnique.org.
We're not talking about representing all CharFields as TEXT, it is about choosing a sane length as the default for the varchar datatype. So if you would not specify max_length, for MySQL it would be varchar(255), for oracle it would be varchar(4000 / bytes_per_char_for NLS_CHARACTERSET) and for PostgreSQL it would be just VARCHAR without a length.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/17C37814-E6A8-4E27-B590-BF9FFF42CB20%40polytechnique.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFO84S5TUwLPf%3DRrGXL4%3Dvf3647CufOsijiznttVQF%2BxYHaBFg%40mail.gmail.com.
Can you please elaborate why the current situation is better?
In practice, most people add max_length=255 everytime by hand. I value your opinion but I fail to understand your reasoning. Could you please explain further (if you have time)?
I think this is why we should be a little more cautious and go for 128 or 100,
rather than "the current maximum all-backend-compatible value".
> That all said, if it were for me I'd deprecate CharField and only support
> TextField and give it an optional max_length (and a way to switch between
> TextArea and LineEdit for UI) -- but that is probably just because on
> Postgres there is no fundamental difference between them. From an enduser
> perspective, it is all text, the only difference is a constraint in length,
No, that's not the only difference. There's also an understanding that
CharField's are one-liners, that is, there is an implicit limitation (usually
only enforced by UI) that newlines are not allowed in the text.
For example, I don't
think there are many CharField's whose contents are interpreted as markup.
In a user perspective, these are really different data types.
I find your suggestion
analogous to a suggestion to remove IntegerField, because "it's just a
FloatField with a constraint on scale".
We could also potentially add another sentinel like DB_MAX_UNICODE_SAFE_LENGTH that works as you expect and is clearly documented, for the sake of 3rd party apps, and comes with the caveat that it produces different behaviour on different databases.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b744bca5-e02e-411e-b9b6-971213aafaa3%40googlegroups.com.
I don't think this is a problem, we could validate that the backend supports it during save then blow up if we detect it doesn't. I think we do that for truncation on MySQL. If the model specifies something that the db doesn't support it's a configuration problem, not a user validation problem.
Voting:
1) should there be a default?
I'm lazy, so I would be happy to have one. Where validation matters you can change it, where it doesn't you don't have to. I'd draw an analogy to (Positive)(Small)IntegerField - I often use the normal one when I mean some variant of validation, or some other max/min value.
2) how to make it easy to have no limit on PG?
If it's truly pg specific, then a contrib.pg field seems fine, though probably call it UnlimitedCharField for lack of ambiguity.
M
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/71e5e743-29bb-4dba-9bf4-6948ab2d1fa9%40googlegroups.com.
Give CharField a default max_length that is consistent across all vendors. It doesn't really matter what the number is other than that it should be large enough to be useful but small enough to work everywhere. I think 100 or 255 are both fine options.
If you set max_length=None explicitly, on Postgres this will use an unlimited varchar, on everything else will raise an exception on migrate.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/dfaaa9d3-dff3-46a3-899f-dd7f4eddfe87n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/468B12C0-2864-4221-9985-044F340E56E1%40tomforb.es.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAJwKpyScwiRJWWebwjQZ4qoQz6_zuWZP9Q_RAs8bxzV0eRMoqQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAHoz%3DMZZN%3D%3D%3D77LQn%3DNAWz%3DazADCuG_bt4xVr5GuNbZW%2Bnu1rg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAJwKpyR6FfkogPHup9gwqQUZ0n8QgQdZDDgCBRdh_m6%3DHui2iA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/f442ac46-e197-459f-8a04-18e0ad0c6058n%40googlegroups.com.