phnx47 / dapper-repositories

CRUD for Dapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error on update using SqlProvider.PostgreSQL

rhmnmbr opened this issue · comments

  • error: 42703: column "app_user" of relation "app_user" does not exist
  • postgre version: PostgreSQL 14.4
  • recorded query:
    UPDATE app_user 
    SET 
      app_user.username = $1, 
      app_user.password_hash = $2, 
      app_user.password_salt = $3, 
      app_user.password_changed_at = $4, 
      app_user.name = $5, 
      app_user.otp = $6, 
      app_user.otp_expires_at = $7, 
      app_user.role_id = $8, 
      app_user.created_at = $9, 
      app_user.updated_at = $10 
    WHERE app_user.id = $11
    

@rhmnmbr83 It is not enough... I just google it: https://stackoverflow.com/questions/17104837/pgsql-error-code-42703-column-does-not-exist

Provide some information, please:

  1. Publish your c# class with attributes
  2. Which method do you use for update?
  3. Publish generated SQL by this library
  4. Publish correct SQL without error for this update

@rhmnmbr83 It is not enough... I just google it: https://stackoverflow.com/questions/17104837/pgsql-error-code-42703-column-does-not-exist

Provide some information, please:

  1. Publish your c# class with attributes
  2. Which method do you use for update?
  3. Publish generated SQL by this library
  4. Publish correct SQL without error for this update
[Table("app_user")]
public class User
{
  [Key, Identity]
  [Column("id")]
  public long Id { get; set; }

  [Column("username")]
  public string Username { get; set; } = string.Empty;

  [Column("password_hash")]
  public byte[]? PasswordHash { get; set; }

  [Column("password_salt")]
  public byte[]? PasswordSalt { get; set; }

  [Column("password_changed_at")]
  public DateTime? PasswordChangedAt { get; set; }

  [Column("name")]
  public string? Name { get; set; }

  [Column("otp")]
  public string? Otp { get; set; }

  [Column("otp_expires_at")]
  public DateTime? OtpExpiresAt { get; set; }

  [Column("role_id")]
  public int RoleId { get; set; }

  [LeftJoin("app_role", "role_id", "id")]
  public Role Role { get; set; } = default!;

  [LeftJoin("b_member", "id", "user_id")]
  public Member Member { get; set; } = default!;

  [Column("created_at")]
  public DateTime CreatedAt { get; set; } = DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Local);

  [UpdatedAt]
  [Column("updated_at")]
  public DateTime? UpdateAt { get; set; }
}

image

UPDATE app_user 
SET 
  app_user.username = $1, 
  app_user.password_hash = $2, 
  app_user.password_salt = $3, 
  app_user.password_changed_at = $4, 
  app_user.name = $5, 
  app_user.otp = $6, 
  app_user.otp_expires_at = $7, 
  app_user.role_id = $8, 
  app_user.created_at = $9, 
  app_user.updated_at = $10 
WHERE app_user.id = $11

image
image

I will setup tests first #153, then we find what's wrong.

@rhmnmbr Hey, can you check it in v1.25.0?

@rhmnmbr Hey, can you check it in v1.25.0?

ok, i will check it soon, thank you

image
still error in v1.25.0

@rhmnmbr Can you reproduce it with a unit test?

@rhmnmbr Can you reproduce it with a unit test?

I'm sorry, but I'm currently busy for a while.

@rhmnmbr Let's close it? Because all current tests are fine. I guess something wrong with your PostgreSQL instance.

@rhmnmbr Let's close it? Because all current tests are fine. I guess something wrong with your PostgreSQL instance.

ok, thank you

Added SQL generation tests - 12353c8.