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

'Note' object has no attribute 'value' #14

Open
drheinheimer opened this issue Aug 29, 2017 · 1 comment
Open

'Note' object has no attribute 'value' #14

drheinheimer opened this issue Aug 29, 2017 · 1 comment

Comments

@drheinheimer
Copy link

I am getting the error Fault(Server: "'Note' object has no attribute 'value'") when trying using get_projects. This seems to be an issue with to_named_tuple in the get_projects call using HydraServer, but I was not able to figure out exactly what the issue was. As far as I can tell my Note is formed correctly (actually, I only have one project note in my database).

In the end, I simply bypassed the to_named_tuple, as it doesn't provide anything of value to me, but we should probably figure this out eventually.

@knoxsp
Copy link
Contributor

knoxsp commented Sep 4, 2017

The issue here seems like a copy-paste error. The DB column is called 'value' whereas the sqlalchemy object uses note_text. The to_named_tuple function assumes column names and sqlalchemy attributes to be consistent.

Long story short, the solution to this is to change the DB column name to note_text.

I have updated the model.py in HydraServer.db to use note_text as the column name.I would have used just 'text' but it seem that that's a reserved word.

MySQL:
alter table tNote change value note_text blob;
Sqlite:
alter table tNote rename to tNoteOriginal;

CREATE TABLE "tNote" (
note_id INTEGER NOT NULL,
ref_key VARCHAR(60) NOT NULL,
note_text BLOB,
created_by INTEGER,
cr_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
scenario_id INTEGER,
project_id INTEGER,
network_id INTEGER,
node_id INTEGER,
link_id INTEGER,
group_id INTEGER,
PRIMARY KEY (note_id),
FOREIGN KEY(created_by) REFERENCES "tUser" (id),
FOREIGN KEY(scenario_id) REFERENCES "tScenario" (scenario_id),
FOREIGN KEY(project_id) REFERENCES "tProject" (project_id),
FOREIGN KEY(network_id) REFERENCES "tNetwork" (network_id),
FOREIGN KEY(node_id) REFERENCES "tNode" (node_id),
FOREIGN KEY(link_id) REFERENCES "tLink" (link_id),
FOREIGN KEY(group_id) REFERENCES "tResourceGroup" (group_id)
);

insert into tNote (ref_key, note_text, created_by, cr_date, scenario_id, project_id, network_id, node_id, link_id, group_id ) select ref_key, value, created_by, cr_date, scenario_id, project_id, network_id, node_id, link_id, group_id from tNoteOriginal;

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

No branches or pull requests

2 participants