0

In the aqueduct ORM i created a table definition which has three columns: Id, username and password. The username and password column is of String type. I'm using a ProstgreSQL database and a table which i manually created (without the migration feature available in aqueduct ORM). The username and password columns in the table are of varchar type. Now the problem is, when i try to insert some values to the table using the ORM Query it produces an error: Specified parameter types do not match column parameter types in query INSERT INTO customers (username,password) VALUES (@v_username:text,@v_password:text).

I've gone through the aqueduct documentation and found out that it only support text type, https://aqueduct.io/docs/db/modeling_data/ Here you can see the datatypes associated with the PostgreSQL column types, Here String is associated with text (only?).

class customers 
{
  @Column(primaryKey: true, autoincrement: true)
  int id;

  @Column(unique: true, nullable: false)
  String username;

  @Column(nullable: false)
  String password;
}

Is there any way i can use varchar instead of text?

  • There is not a way to use varchar. In Postgres, varchar and text are the same structure - there's just a length limit. YOu can provide a length length with a ORM Validate annotation. See also: https://stackoverflow.com/questions/4848964/postgresql-difference-between-text-and-varchar-character-varying – Joe Conway Jun 17 '19 at 14:45
  • 1
    Actually, text fields are more efficient (unlike in other RDBMS), because a varchar() has to keep ensuring the text is short enough, but a text just takes what you throw at it. – Randal Schwartz Jun 18 '19 at 02:47
  • i think i should use text then, thank you guys! – Arjunraj kokkadan Jun 18 '19 at 02:56

0 Answers0