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。
是什么导致了这种情况,我该如何解决这个问题?