Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

PG::Error: ERROR: zero-length delimited identifier at or near """" -- nifty authentication #160

@cheeby

Description

@cheeby

Hi,

I'm getting this error on what had been a perfectly functional authentication system using nifty auth.

Could not log "sql.active_record" event. NoMethodError: undefined method `name' for nil:NilClass
PG::Error: ERROR: zero-length delimited identifier at or near """"
LINE 1: SELECT "users".* FROM "users" WHERE "users"."" = $1 LIMIT

This happens when the current_user method is called. What's odd is that in rails db, this works:

dgap=> select first_name, email from users where id=1;
-[ RECORD 1 ]--------------------------------------
first_name | bridget
email | bridget@cnn.com

but in console I get the same error as above:

ruby -> User.find(1)
Could not log "sql.active_record" event. NoMethodError: undefined method `name' for nil:NilClass
ActiveRecord::StatementInvalid: PG::Error: ERROR: zero-length delimited identifier at or near """"
LINE 1: SELECT "users".* FROM "users" WHERE "users"."" = $1 LIMIT ...

and

ruby -> User

returns the model's attributes.

It's as if it suddenly can't tell what column to id with. All required columns contain values. This started happening after I made a back up of the users table,

dgap => create table users_bak as select * from users;

Then I removed some users:

dgap => delete from users where id > 1;

The user with an id of one is definitely still there.

So I restored the table:

dgap=> alter table users rename to users_borken;
dgap=> alter table users_bak rename to users;

and I'm still getting the same errors.

lib/controller_authentication.rb:
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end

Untouched.

Thoughts? Any insight would be greatly appreciated.

Steve

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions