Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create registers... _packed_id has a not null constraint. #5

Open
jamiefolsom opened this issue Oct 31, 2014 · 7 comments
Open
Assignees
Labels

Comments

@jamiefolsom
Copy link
Collaborator

Hi @christopheryork!

I am running into an issue in register#new; since _packed_id has been created (by repertoire-faceting I think), and includes a not null constraint, I can't create new registers since the model is unaware of that attribute, and doesn't know how to set a value on it that is appropriately "packed".

I could add a migration to alter the column to allow null values, I could add the attribute to attr_accessible on the model, and explicitly set a value on the object at create time, but as I recall this column is managed by repertoire-faceting.

Thoughts on the best way to manage this?

Thanks!

Jamie

@jamiefolsom
Copy link
Collaborator Author

Or rather registers#create.

@forestofarden
Copy link
Contributor

Hi Jamie -

Thanks for the message, and sorry for the delay as I was away for the
weekend. I'll take a look at your issue tomorrow and get back to you.

However at first glance your read of the situation sounds correct. The
database should fill this field by default with no rails connections. More
soon.

C

On Friday, 31 October 2014, Jamie Folsom [email protected] wrote:

Hi @christopheryork https://github.com/christopheryork!

I am running into an issue in register#new; since _packed_id has been
created (by repertoire-faceting I think), and includes a not null
constraint, I can't create new registers since the model is unaware of that
attribute, and doesn't know how to set a value on it that is appropriately
"packed".

I could add a migration to alter the column to allow null values, I could
add the attribute to attr_accessible on the model, and explicitly set a
value on the object at create time, but as I recall this column is managed
by repertoire-faceting.

Thoughts on the best way to manage this?

Thanks!

Jamie


Reply to this email directly or view it on GitHub
#5.

@jamiefolsom
Copy link
Collaborator Author

Hi @christopheryork,

No worries. I solved this for now in CFRP by modifying the register model to explicitly set the next_val for the _packed_id before_create. Have a look at my branch in that repo.

I am guessing you have ideas for a better solution though. Seems that should not be a concern for the implementing application.

Thanks!

Jamie

@forestofarden
Copy link
Contributor

Hi @jamiefolsom,

Absolutely, this should not be a concern for the implementing application.
The stackoverflow entry you cite summarizes the situation well.

I've confirmed that repertoire-faceting sets the default value correctly,
but rails then overrides it with the wrong one. The issue will require more
probing.

For the moment, your work around is good. Once I have a solution I'll patch
it in.

On Tue, Nov 4, 2014 at 2:31 PM, Jamie Folsom [email protected]
wrote:

See:

https://github.com/hyperstudio/cfrp/blob/jf-import-120/app/models/register.rb#L82

And:

https://github.com/hyperstudio/cfrp/blob/jf-import-120/app/models/register.rb#L132-L134


Reply to this email directly or view it on GitHub
#5 (comment)
.

@jamiefolsom
Copy link
Collaborator Author

Hi @christopheryork -- Sounds great. Thanks!

@jamiefolsom
Copy link
Collaborator Author

Bump -- just ran into this on the plays model too. Let's discuss when you have a moment. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants