Skip to content

Cannot save array values on record creation #914

@AlexanderBich

Description

@AlexanderBich

When I try to create a record with array property inside it ingores provided array values and saves a record without them.
P.S. edit works fine, so the issue is only with creation

Installed libraries and their versions

  • adminjs@5.2.1
  • @adminjs/express@4.0.0
  • @adminjs/nestjs@3.0.0
  • @adminjs/typeorm@2.0.0

PostgreSQL:13.3

To Reproduce
Steps to reproduce the behavior:

  1. Click on 'Create new' on resource with array field inside
  2. Fill array field with values
  3. Bug: It will create record without those provided array values

Expected behavior
It should save array values on creation of a new record

Screenshots
If applicable, add screenshots to help explain your problem.

image

After creation:
image

AdminJSOptions with schema
Paste your AdminJS config with database schema if it could be related to the issue

AdminJS resource config

CompanyResource = {
  resource: Company,
  options: {
    navigation: {
      name: null,
    },
    properties: {
      id: {
        name: 'string',
        isVisible: false,
      },
      name: {
        type: 'string',
      },
      email: {
        type: 'string',
      },
      phoneNumbers: {
        isArray: true,
        type: 'string',
        isVisible: { list: false, filter: false, show: true, edit: true },
      },
    },
  },
};

database schema:

-- auto-generated definition
create table companies
(
    id            uuid default gen_random_uuid() not null
        constraint "PK_d4bc3e82a314fa9e29f652c2c22"
            primary key,
    name          varchar                        not null,
    email         varchar                        not null,
    socials       jsonb,
    phone_numbers text[]                         not null,
    comments      text
);

alter table companies
    owner to postgres;

Additional context
Before I added default value as empty array array[]::text[] to phone_numbers it was throwing me null violation exception from postgres.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions