2
運行此代碼:使用JSON列雄辯模型 'UNION ALL SELECT' SQL語法錯誤
App\ExampleJson::create(["name" => "example"]);
在此模式:
namespace App;
use Illuminate\Database\Eloquent\Model;
class ExampleJson extends Model
{
public $timestamps = false;
protected $fillable = [
"name",
"jsontest",
];
protected $casts = [
"jsontest" => "array",
];
protected $attributes = [
"jsontest" => [],
];
}
創造了這個遷移:
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateExampleJsonsTable extends Migration
{
public function up()
{
Schema::create('example_jsons', function (Blueprint $table) {
$table->increments('id');
$table->string("name");
$table->json("jsontest")->default("{}");
});
}
public function down()
{
Schema::dropIfExists('example_jsons');
}
}
它給我以下例外:
Illuminate\Database\QueryException with message 'SQLSTATE[HY000]: General error: 1 near ")": syntax error (SQL: insert into "example_jsons"() select union all select)'
我對我的數據庫和Laravel 5.4使用SQLite。
是什麼導致了這種情況,我該如何解決這個問題?