MySQL is returning an alphabetically sorted column names when using Laravel's Schema::getColumnListing('table_name');

Viewed 148

I have a table named tags with the following schema:

id
name
icon
type

enter image description here

If I use Laravel's Schema::getColumnListing('tags'), it returns an alphabetically sorted array of the column names:

array:4 [▼
  0 => "icon"
  1 => "id"
  2 => "name"
  3 => "type"
]

Am I right to expect that the returned array should be preserving the original column order? Like:

array:4 [▼
  0 => "id"
  1 => "name"
  2 => "icon"
  3 => "type"
]

Additional details, I'm using:

  • PHP 7.4.3
  • mysql Ver 8.0.21-0ubuntu0.20.04.4 for Linux on x86_64 ((Ubuntu))
  • Laravel version is 5.8
0 Answers
Related