Menu

#144 Setting "Required" (NOT NULL) property on column while creating table

2.1.9
closed
nobody
None
1
2017-10-03
2017-09-27
No

I see from this thread how I can set the "Required" (NOT NULL) property on an existing column. However, if I try to do that while creating the table ...

new TableBuilder("Table1")
        .addColumn(new ColumnBuilder("id", DataType.LONG)
                .setAutoNumber(true))
        .addColumn(new ColumnBuilder("txt", DataType.TEXT)
                .setLengthInUnits(50)
                .putProperty(PropertyMap.REQUIRED_PROP, true))
        .addIndex(new IndexBuilder(IndexBuilder.PRIMARY_KEY_NAME)
                .addColumns("id").setPrimaryKey())
        .toTable(db);

 
... I wind up with a table that Microsoft Access cannot manipulate. I can open the database itself, but as soon as I try to work with the table I get the error

CannotOpen.png

Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt.

 
If I simply omit the .putProperty call ...

new TableBuilder("Table1")
        .addColumn(new ColumnBuilder("id", DataType.LONG)
                .setAutoNumber(true))
        .addColumn(new ColumnBuilder("txt", DataType.TEXT)
                .setLengthInUnits(50))
        .addIndex(new IndexBuilder(IndexBuilder.PRIMARY_KEY_NAME)
                .addColumns("id").setPrimaryKey())
        .toTable(db);

 
... then the resulting table is accessible.

A bit of poking around seems to suggest that it might be related to a Property being created whose name is an empty string, but it's tricky to investigate using the tools at my disposal because Jackcess Column#getProperties seems to think that the column has none, and MSACCESS won't work with the table at all.

Discussion

  • James Ahlborn

    James Ahlborn - 2017-10-02

    alright, think i figired it out. access doesn't like the "empty" property map for the table.

     
  • James Ahlborn

    James Ahlborn - 2017-10-03
    • status: open --> closed
    • Group: Unassigned --> 2.1.9
     
  • James Ahlborn

    James Ahlborn - 2017-10-03

    Fixed in trunk, will be in the 2.1.9 release.

     

Log in to post a comment.

MongoDB Logo MongoDB