servicestackormlite-servicestackservicestack-autoquery

ServiceStack AutoQuery - Table not accessibele


When I try to use the IncludeTables property, the table is not generated or is not accessible using the AutoQuery API. When calling /metadata I only see these two endpoints:

Is there a way to debug this or does someone know why the table is not picked up by AutoQuery?

Edited: When I call https://localhost:5001/crud/tables I can see the product table as result ...

appHost.Plugins.Add(new AutoQueryFeature
    {
        MaxLimit = 1000,
        GenerateCrudServices = new GenerateCrudServices
        {
            AutoRegister = true,
            CreateServices = new List<CreateCrudServices>
            {
                new CreateCrudServices
                {
                    IncludeTables = new List<string> { "product"}
                },

            }
        }
    });

Update:

@mythz I've inspected the table schema, but did not find any errors (MySql). These are the columns:

[
  {
     "ColumnName":"id",
     "ColumnOrdinal":1,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":true,
     "BaseColumnName":"id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":false,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) PRIMARY KEY"
  },
  {
     "ColumnName":"version_id",
     "ColumnOrdinal":2,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":true,
     "BaseColumnName":"version_id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":false,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) PRIMARY KEY"
  },
  {
     "ColumnName":"auto_increment",
     "ColumnOrdinal":3,
     "ColumnSize":11,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"auto_increment",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Int32",
     "AllowDBNull":false,
     "ProviderType":3,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":true,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"INT",
     "ColumnDefinition":"INT NOT NULL"
  },
  {
     "ColumnName":"parent_id",
     "ColumnOrdinal":4,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"parent_id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":true,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) NULL"
  },
  {
     "ColumnName":"parent_version_id",
     "ColumnOrdinal":5,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"parent_version_id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":true,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) NULL"
  },
  {
     "ColumnName":"media_id",
     "ColumnOrdinal":6,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"media_id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":true,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) NULL"
  },
  {
     "ColumnName":"cms_page_id",
     "ColumnOrdinal":7,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"cms_page_id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":true,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) NULL"
  },
  {
     "ColumnName":"cms_page_version_id",
     "ColumnOrdinal":8,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"cms_page_version_id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":false,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) NOT NULL"
  },
  {
     "ColumnName":"product_stream_id",
     "ColumnOrdinal":9,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"product_stream_id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":true,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) NULL"
  },
  {
     "ColumnName":"product_assignment_type",
     "ColumnOrdinal":10,
     "ColumnSize":32,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"product_assignment_type",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.String",
     "AllowDBNull":false,
     "ProviderType":253,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"VARCHAR",
     "ColumnDefinition":"VARCHAR(32) NOT NULL"
  },
  {
     "ColumnName":"path",
     "ColumnOrdinal":11,
     "ColumnSize":-1,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"path",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.String",
     "AllowDBNull":true,
     "ProviderType":752,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":true,
     "IsReadOnly":false,
     "DataTypeName":"VARCHAR",
     "ColumnDefinition":"VARCHAR NULL"
  },
  {
     "ColumnName":"after_category_id",
     "ColumnOrdinal":12,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"after_category_id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":true,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) NULL"
  },
  {
     "ColumnName":"after_category_version_id",
     "ColumnOrdinal":13,
     "ColumnSize":16,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"after_category_version_id",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte[]",
     "AllowDBNull":true,
     "ProviderType":754,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"BLOB",
     "ColumnDefinition":"BLOB(16) NULL"
  },
  {
     "ColumnName":"level",
     "ColumnOrdinal":14,
     "ColumnSize":11,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"level",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.UInt32",
     "AllowDBNull":false,
     "ProviderType":503,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"INT",
     "ColumnDefinition":"INT NOT NULL"
  },
  {
     "ColumnName":"active",
     "ColumnOrdinal":15,
     "ColumnSize":1,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"active",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Boolean",
     "AllowDBNull":false,
     "ProviderType":1,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"tinyint",
     "ColumnDefinition":"TINYINT(1) NOT NULL"
  },
  {
     "ColumnName":"child_count",
     "ColumnOrdinal":16,
     "ColumnSize":11,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"child_count",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.UInt32",
     "AllowDBNull":false,
     "ProviderType":503,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"INT",
     "ColumnDefinition":"INT NOT NULL"
  },
  {
     "ColumnName":"display_nested_products",
     "ColumnOrdinal":17,
     "ColumnSize":1,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"display_nested_products",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte",
     "AllowDBNull":false,
     "ProviderType":501,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"INT",
     "ColumnDefinition":"INT NOT NULL"
  },
  {
     "ColumnName":"visible",
     "ColumnOrdinal":18,
     "ColumnSize":1,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"visible",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.Byte",
     "AllowDBNull":false,
     "ProviderType":501,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"INT",
     "ColumnDefinition":"INT NOT NULL"
  },
  {
     "ColumnName":"type",
     "ColumnOrdinal":19,
     "ColumnSize":32,
     "NumericPrecision":0,
     "NumericScale":0,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"type",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.String",
     "AllowDBNull":false,
     "ProviderType":253,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"VARCHAR",
     "ColumnDefinition":"VARCHAR(32) NOT NULL"
  },
  {
     "ColumnName":"created_at",
     "ColumnOrdinal":20,
     "ColumnSize":23,
     "NumericPrecision":0,
     "NumericScale":3,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"created_at",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.DateTime",
     "AllowDBNull":false,
     "ProviderType":12,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"DATETIME",
     "ColumnDefinition":"DATETIME(23) NOT NULL"
  },
  {
     "ColumnName":"updated_at",
     "ColumnOrdinal":21,
     "ColumnSize":23,
     "NumericPrecision":0,
     "NumericScale":3,
     "IsUnique":false,
     "IsKey":false,
     "BaseColumnName":"updated_at",
     "BaseSchemaName":"shopware_6_demo",
     "BaseTableName":"category",
     "DataType":"System.DateTime",
     "AllowDBNull":true,
     "ProviderType":12,
     "IsAliased":false,
     "IsExpression":false,
     "IsAutoIncrement":false,
     "IsRowVersion":false,
     "IsHidden":false,
     "IsLong":false,
     "IsReadOnly":false,
     "DataTypeName":"DATETIME",
     "ColumnDefinition":"DATETIME(23) NULL"
  }
]

Solution

  • Once you use IncludeTables the table selection becomes opt-in "white-list". The CancelRequest and GetFile are built-in APIs that are not relevant to AutoQuery.

    You can test what Tables AutoQuery resolves by calling the static method, e.g:

    var tableSchemas = GenerateCrudServices.GetTableSchemas(dbFactory, 
        includeTables:new List<string> { "product" });
    

    If you leave of the off the includeTables filter, you can inspect the resulting table metadatas from the specified schema (or default if none is provided) where you can inspect the name from the RDBMS metadata with tableSchemas[0].Name.