bumbummen99 / LaravelShoppingcart

A simple shopping cart implementation for Laravel
MIT License
501 stars 228 forks source link

SQLSTATE[42000]: Syntax error or access violation #169

Closed pixsolution closed 2 years ago

pixsolution commented 2 years ago

Hello! when I runned the migration generated by this command php artisan vendor:publish --provider="Gloudemans\Shoppingcart\ShoppingcartServiceProvider" --tag="migrations"

I get the following error:

Illuminate\Database\QueryException SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table ` (identifiervarchar(255) not null,instancevarchar(255) not null,contentlongtext not null,created_attimestamp null,updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

at C:\xampp\htdocs\web-site\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671 667| // If an exception occurs when attempting to run a query, we'll format the error 668| // message to include the bindings with SQL, which will make this exception a 669| // lot more helpful to the developer instead of just the database's errors. 670| catch (Exception $e) {

671| throw new QueryException( 672| $query, $this->prepareBindings($bindings), $e 673| ); 674| } 675|

1 C:\xampp\htdocs\web-site\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDO\Exception.php:18 Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''")

2 C:\xampp\htdocs\web-site\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:84 Doctrine\DBAL\Driver\PDO\Exception::new(Object(PDOException))

Why?

Regards

bumbummen99 commented 2 years ago

Looks like it does resolve the config to an empty table name. What is the content of your cart.php in configs?

pixsolution commented 2 years ago

Hi, the content is this:

`return [

/*
|--------------------------------------------------------------------------
| Gross price as base price
|--------------------------------------------------------------------------
|
| This default value is used to select the method to calculate prices and taxes
| If true the item price is managed as a gross price, so taxes will be calculated by separation/exclusion
|
*/

'calculator' => \Gloudemans\Shoppingcart\Calculation\DefaultCalculator::class,

/*
|--------------------------------------------------------------------------
| Default tax rate
|--------------------------------------------------------------------------
|
| This default tax rate will be used when you make a class implement the
| Taxable interface and use the HasTax trait.
|
*/

'tax' => 21,

/*
|--------------------------------------------------------------------------
| Shoppingcart database settings
|--------------------------------------------------------------------------
|
| Here you can set the connection that the shoppingcart should use when
| storing and restoring a cart.
|
*/

'database' => [

    'connection' => null,

    'table' => 'shoppingcart',

],

/*
|--------------------------------------------------------------------------
| Destroy the cart on user logout
|--------------------------------------------------------------------------
|
| When this option is set to 'true' the cart will automatically
| destroy all cart instances when the user logs out.
|
*/

'destroy_on_logout' => false,

/*
|--------------------------------------------------------------------------
| Default number format
|--------------------------------------------------------------------------
|
| This defaults will be used for the formatted numbers if you don't
| set them in the method call.
|
*/

'format' => [

    'decimals' => 2,

    'decimal_point' => '.',

    'thousand_separator' => ',',

],

]; ` I didn't touch it after installation

Regards

bumbummen99 commented 2 years ago

That is strange, it should resolve cart.database.table to shoppingcart but it resolves empty as per your error ...create table `` (identifier...

https://github.com/bumbummen99/LaravelShoppingcart/blob/1c50fb564826b6ee748d2d9afad7447b6884166e/src/Database/migrations/2018_12_23_120000_create_shoppingcart_table.php#L14

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days