Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializer Group #1213

Closed
elvispdosreis opened this issue Jun 8, 2020 · 1 comment
Closed

Serializer Group #1213

elvispdosreis opened this issue Jun 8, 2020 · 1 comment

Comments

@elvispdosreis
Copy link

Q A
Bug report? no
Feature request? no
BC Break report? no
RFC? no

Steps required to reproduce the problem

query count

SELECT
	COUNT(*) AS dctrn_count
FROM
	(
		SELECT DISTINCT
			id_produto_0
		FROM
			(
				SELECT
					p0_.id_produto AS id_produto_0,
					p0_.produto AS produto_1,
					p0_.titulo_nfe AS titulo_nfe_2,
					p0_.codigo AS codigo_3,
					p0_.erp AS erp_4,
					p0_.cod_barras AS cod_barras_5,
					p0_.referencia AS referencia_6,
					p0_.ncm AS ncm_7,
					p0_.exibir AS exibir_8,
					p0_.excluir AS excluir_9,
					p0_.created_at AS created_at_10,
					p0_.updated_at AS updated_at_11,
					p1_.id AS id_12,
					p1_.valor_compra AS valor_compra_13,
					p1_.valor_venda AS valor_venda_14,
					p1_.promocao_valor AS promocao_valor_15,
					p1_.promocao_inicio AS promocao_inicio_16,
					p1_.promocao_final AS promocao_final_17,
					e2_.id AS id_18,
					e2_.estoque AS estoque_19
				FROM
					produtos p0_
				LEFT JOIN precos p1_ ON p0_.id_produto = p1_.fk_produto
				LEFT JOIN estoques e2_ ON p0_.id_produto = e2_.fk_produto
			) dctrn_result
	) dctrn_table;

query result

SELECT
	p0_.id_produto AS id_produto_0,
	p0_.produto AS produto_1,
	p0_.titulo_nfe AS titulo_nfe_2,
	p0_.codigo AS codigo_3,
	p0_.erp AS erp_4,
	p0_.cod_barras AS cod_barras_5,
	p0_.referencia AS referencia_6,
	p0_.ncm AS ncm_7,
	p0_.exibir AS exibir_8,
	p0_.excluir AS excluir_9,
	p0_.created_at AS created_at_10,
	p0_.updated_at AS updated_at_11,
	p1_.id AS id_12,
	p1_.valor_compra AS valor_compra_13,
	p1_.valor_venda AS valor_venda_14,
	p1_.promocao_valor AS promocao_valor_15,
	p1_.promocao_inicio AS promocao_inicio_16,
	p1_.promocao_final AS promocao_final_17,
	e2_.id AS id_18,
	e2_.estoque AS estoque_19,
	p0_.fk_fabricante AS fk_fabricante_20,
	p0_.fk_fornecedor AS fk_fornecedor_21,
	p0_.fk_taxonomia AS fk_taxonomia_22,
	p0_.fk_status AS fk_status_23,
	p0_.fk_parcelamento AS fk_parcelamento_24,
	p0_.fk_descricao AS fk_descricao_25,
	p0_.fk_unidade AS fk_unidade_26,
	p1_.fk_produto AS fk_produto_27,
	p1_.fk_modalidade AS fk_modalidade_28,
	e2_.fk_produto AS fk_produto_29
FROM
	produtos p0_
LEFT JOIN precos p1_ ON p0_.id_produto = p1_.fk_produto
LEFT JOIN estoques e2_ ON p0_.id_produto = e2_.fk_produto
LIMIT 25

doctrine

$paginator = new Paginator($query, $fetchJoinCollection = false);
$total = $paginator->count();
$results = $paginator->getIterator()->getArrayCopy();

Expected Result

the count it does correctly, it ignores the left join with the price table that contains more than one record for the product.
Plus the select that brings the result he makes a limit bringing only 10, then the jsm serializes the products and prices together this result is different from the expected, where a result with 10 items is expected and each item contains its prices

Actual Result

image

@goetas
Copy link
Collaborator

goetas commented Jun 10, 2020

I think that here the issue is on how you are using doctrine. A similar problem to what you have described is https://stackoverflow.com/questions/26401620/how-to-limit-results-of-a-left-join-with-doctrine-dql

@goetas goetas closed this as completed Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants