GithubHelp home page GithubHelp logo

Comments (5)

Zac-HD avatar Zac-HD commented on June 21, 2024

It's been five years since I looked into that, but iirc the idea was to avoid automatically generating values for auto-incrementing index fields. If you want that to be generated anyway, you can pass e.g. id_=... - the field name, and literal ... as the argument.

If that does in fact solve your problem, I'd prefer to keep the existing behavior because being too 'helpful' has gone wrong here in the past.

from hypothesis.

rascalking avatar rascalking commented on June 21, 2024

Sorry, I did a bad job explaining. I actually have the opposite problem...I want hypothesis to not generate a strategy for my id column, but I don't think I can do that. Because I defined the autoid column myself, instead of letting django do it, the "is this a field I should skip" check fails (because field.auto_created is false, where it's true when django creates the field), and from_model() calls from_field() to generate a strategy for it.

A simplified version of the model:

class Group(models.Model):
    groupid = models.AutoField(primary_key=True)

from hypothesis.

Zac-HD avatar Zac-HD commented on June 21, 2024

Oh, I see - yeah, this seems like something I'd be happy to accept a PR for. I guess we could do something like and not (field.auto_created or isinstance(field, AutoField))? You're more familiar with Django and this use-case than I am, though.

from hypothesis.

rascalking avatar rascalking commented on June 21, 2024

This was a fun one...it turns out auto_created gets set on a bunch of things I didn't realize, so yay for learning new things while trying to fix a different thing.

The cleanest fix seemed to me to be to add in a and not isinstance(field, dm.AutoField) clause alongside the and not field.auto_created.

from hypothesis.

tybug avatar tybug commented on June 21, 2024

closed by #3984

from hypothesis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.