<?php
declare(strict_types=1);
ob_start();require __DIR__.'/CompileOriginal.php';ob_end_clean();$assertions=0;
$assert=static function($ok,$message)use(&$assertions){$assertions++;if(!$ok)throw new RuntimeException($message);};
foreach(['mysql'=>\think\db\builder\Mysql::class,'dm'=>\app\common\database\DmBuilder::class] as $dialect=>$builder){\cores\BaseModel::$storeId=2147001111;$db=new \think\DbManager();$db->setConfig(['default'=>'mysql','connections'=>['mysql'=>['type'=>'\\'.OrderReadSqlCapture::class,'builder'=>$builder,'prefix'=>'yoshop_','fields_strict'=>false]]]);$class='app\\'.$module.'\\model\\Order';
foreach([123,'123',0,-1] as $id){$class::detail($id,['goods.image']);$cap=$db->connect('mysql');$sql=str_replace('`','',$cap->sql['detail']);$assert(preg_match('/(?:\s|\.)order_id\s*=/',$sql)===1,$dialect.' scalar must use real order_id');$assert(preg_match('/(?:\s|\.)id\s*=/',$sql)!==1,$dialect.' no nonexistent id');$assert(in_array((int)$id,$cap->values['detail'],true),$dialect.' scalar int binding');$assert(in_array(2147001111,$cap->values['detail'],true),$dialect.' tenant scope');}
foreach([['order_id'=>321],['id'=>654],['order_no'=>"订单 中文' \\"],['store_id'=>2147001112,'order_id'=>88]] as $where){$before=$where;$class::detail($where,['goods.image']);$cap=$db->connect('mysql');$sql=str_replace('`','',$cap->sql['detail']);$assert($where===$before,'Array caller unchanged');foreach($where as $k=>$v){$assert(strpos($sql,$k)!==false,'Array key preserved '.$k);$assert(in_array($v,$cap->values['detail'],true),'Array value binding preserved '.$k);}$assert(in_array(2147001111,$cap->values['detail'],true),'Array tenant scope remains');}}
echo json_encode(['module'=>$module,'assertions'=>$assertions,'PDO_opens'=>0,'SQL_executed'=>0,'array_inputs_preserved'=>true]),"\n";
