1

I'm running a Laravel app in a Docker container that is using Ubuntu as its base image. After upgrading from Ubuntu 20.04 to 22.04, SQL Server date type columns started returning with a different format.

Migration:

Schema::create('my_table', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->date('due_date');
});

Query: $dueDate = DB::table('my_table')->find(1)->due_date;

On Ubuntu 20.04, $dueDate = '2020-01-31', while on 22.04, $dueDate = 'Jan 31 2020 12:00:00:AM'.

Aside from upgrading Ubuntu, I did not make any other changes.

Dockerfile:

FROM ubuntu:22.04 #Switched from ubuntu:20.04

RUN apt-get update && apt-get install -y software-properties-common
RUN add-apt-repository ppa:ondrej/php

RUN apt-get update && apt-get install -y \
  gnupg2 \
  nginx \
  php8.1 \
  php8.1-bcmath \
  php8.1-curl \
  php8.1-fpm \
  php8.1-gd \
  php8.1-intl \
  php8.1-mbstring \
  php8.1-memcached \
  php8.1-redis \
  php8.1-sybase \
  php8.1-xdebug \
  php8.1-xml \
  php8.1-zip \
  && rm -rf /var/lib/apt/lists/*

COPY . /var/www/html
WORKDIR /var/www/html
CMD tail -f /var/log/nginx/*.log
  • PHP version: 8.1.13
  • Laravel version: 9.43.0
  • SQL Server version: 2017

I am literally stumped. Any help will be very much appreciated! Thank you in advance!

Yaakov
  • 91
  • 10
  • don't know anything about laravel so won't even charge my normal $0.02 ... sounds like some sort of locale issue; start by running `locale` on both sytems and look for differences in the output; one option for updating your login's locale settings: `localectl set-locale =""`, eg, `localectl set-locale LC_TIME="C.UTF-8"` – markp-fuso Dec 16 '22 at 01:50
  • @markp-fuso Thanks for taking the time. See my answer below. – Yaakov Dec 20 '22 at 18:14

1 Answers1

1

Here is the answer to my own question:

A new version of Microsoft TDS (Tabular Data Stream) was affecting the date format. I do not fully understand everything, but this is the basic story.

  1. My app was using the php-sybase driver for SQL Server.
  2. The TDS was being set to version 8.
  3. At some time Microsoft changed their versioning, at which point TDS version 8 became 7.1. (They have since released 7.2, 7.3 and 7.4) See http://www.freetds.org/userguide/tdshistory.html#ftn.idm66573648
  4. Although I was explicitly setting the version to 8, somewhere along the process it was being mapped to 7.1.
  5. The newest SQL Server 2022 was released with a new version of TDS 8.0. See https://learn.microsoft.com/en-us/sql/relational-databases/security/networking/tds-8-and-tls-1-3?view=sql-server-ver16
  6. Ubuntu 22.04 was finding the new TDS 8 instead of mapping back to 7.1.

It was a wild goose chase...

Yaakov
  • 91
  • 10
  • I'm not following some of this but kudos for going down that rabbit hole, in the briar patch, to find the issue – markp-fuso Dec 20 '22 at 18:19