diff --git a/src/MathOptLazy.jl b/src/MathOptLazy.jl index f9020af..4ad5156 100644 --- a/src/MathOptLazy.jl +++ b/src/MathOptLazy.jl @@ -440,7 +440,7 @@ function MOI.get( attr::MOI.ListOfConstraintIndices{F,S}, ) where {F<:MOI.AbstractScalarFunction,S<:MOI.AbstractScalarSet} ret = MOI.get(model.inner, attr) - if (data = _data(model, F, S)) !== nothing + if (data = _maybe_data(model, F, S)) !== nothing in_model = Set(ci for (ci, z) in zip(data.index, data.active) if z) ret = filter!(ci -> !(ci in in_model), ret) end diff --git a/test/runtests.jl b/test/runtests.jl index 153592b..2afa1bd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -101,6 +101,9 @@ function _basic_constraint_test_helper( F, S, IS = typeof(constraint_function), typeof(set), typeof(inner_set) @test MOI.supports_constraint(model, F, S) @test MOI.get(model, MOI.NumberOfConstraints{F,S}()) == 0 + @test isempty(MOI.get(model, MOI.ListOfConstraintIndices{F,S}())) + @test MOI.get(model, MOI.NumberOfConstraints{F,IS}()) == 0 + @test isempty(MOI.get(model, MOI.ListOfConstraintIndices{F,IS}())) c = MOI.add_constraint(model, constraint_function, set) if activate data = MathOptLazy._data(model, F, IS)