Unsigned int-type columns are not added in hook_views_data()

Created on 18 July 2022, almost 2 years ago
Updated 23 April 2023, about 1 year ago

Problem/Motivation

I'm using the latest stable version of this module to build reports in Drupal 9 displaying data from some custom MariaDB tables. We are using MariaDB 10.5. One of our integer columns is not returned to views in view_custom_table_views_data(). I have been debugging the issue and it is related to the integer column being unsigned. The MySQL DESCRIBE query returns for example "smallint unsigned" for an unsigned column and this string is of course matched to the list of integer types.

Steps to reproduce

  1. Create a custom table, for example in the Drupal db, with one or more unsigned integer columns.
  2. Add the table as custom table in views custom table.
  3. Create a new view using the custom table and see that the unsigned columns are missing in the overlay adding fields to the view.

Proposed resolution

view_custom_table_views_data() already handle round brackets in varchar columns by doing a string search on the column type. A similar solution could be implemented for unsigned columns. E.g. searching for " unsigned" in the column type or exploding the column type by space and checking the last item in the results array. If we have a match then strip " unsigned" from the column type.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇩🇰Denmark beltofte Copenhagen 🇩🇰

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024